Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Issues implementing the observer pattern


I've been trying to create a basic implementation of the observer pattern, for events such as the player taking damage and the HUD needing to update as a result. While I am aware that I can do things like that straight from my player class, I would prefer to keep things tidy.

To that end, I've attempted to create the pub-sub pattern, and they seem to be OK on paper, but my publisher's subscriber list keeps resetting during gameplay (I add the HUD as subscriber in my GameMode's BeginPlay()). I assume this is because the player class which inherits it gets respawned, and the data in the TArray doesn't persist.

Relevant bits of code:

I can confirm that the IPublisher::Subscribe function does get called, and that the container size is indeed 1 after the call, but the IPublisher destructor gets called as well, afterwards, so my Update() calls will do nothing.

So, what I would like to know is: what am I doing wrong? What should I do to keep my list of subscribers even when the player respawns?

Thanks in advance!

Product Version: UE 4.14
more ▼

asked Jan 28 '17 at 06:44 AM in C++ Programming

avatar image

1 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question