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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Event is called twice when bound in constructor (c++)

Hey there!

I am using unreals delegate system to create an event manager for my game.

Everything is rigged up and working well, but I have one small issue.

If I call my SubscribeToEvent function in the constructor of my class (a pawn), the bound function is called twice. However, if I call my SubscribeToEvent function in Begin Play, it is called once.

Here is my subscribe function (called in the constructor or begin play)

 template < class UserClass >
 static FDelegateHandle Subscribe(UserClass * InUserObject, void(UserClass::*InFunc)(class HGEvent* receivedEvent))
     FEventManagerDelegate Listener;
      Listener.BindUObject(InUserObject, InFunc);
     return m_Event.Add(Listener);

and here is my send event function, called once in beginplay for testing.

 void EventManager::SendEvent(HGEvent* givenEvent)

just in case, here is the function I use for testing: void APlayerCameraPawn::BeginPlay() { Super::BeginPlay();

 SubscribeToEvent(this, &APlayerCameraPawn::HandleEvent);
 CenterCameraEvent* newEvent = new CenterCameraEvent(FVector(0, 0, 0));


However, it is called twice if SubscribeToEvent is called in the constructor instead of begin play.

Hope you can help! cheers, dan

Product Version: UE 4.10
more ▼

asked Mar 09 '16 at 09:41 PM in C++ Programming

avatar image

18 3 4 6

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

1 answer: sort voted first
more ▼

answered Mar 10 '16 at 12:49 AM

avatar image

1k 38 13 60

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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