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"

Trouble with syntax for adding function refs to event

I'm going through the pseudo-tutorial at https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Delegates/Events/index.html , and I've managed to declare my event, but I'm having a lot of trouble figuring out the correct syntax to add a function to it. The declaration looks and compiles fine:

 DECLARE_EVENT_OneParam(UCombat, FTickEvent, float);
 UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
 class LEARNINGPROJECT_API UCombat : public AActor
 FTickEvent TickEvent; //Event I want a function to subscribe to
 void FlowTowards(float FrameDeltaTime); //Function I want to subscribe to event

However, I get a compiler error when I attempt to add my function to my event in the .cpp:

 void UCombat::InitializeStuff(){

"error C2664: 'FDelegateHandle TBaseMulticastDelegate::Add(const TBaseDelegate &)' : cannot convert argument 1 from 'void (__cdecl UCombat:: )(float)' to 'IBaseDelegateInstance ' Info There is no context in which this conversion is possible"

My best guess is that this is expecting me to give FloatTowards an argument when I add it to TickEvent, but I don't understand why it would need one- the entire point of using the event-function structure is to let me run FloatTowards by calling TickEvent.Broadcast(someNumber)

Product Version: UE 4.8
more ▼

asked Aug 04 '15 at 02:47 AM in C++ Programming

avatar image

251 96 66 83

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

2 answers: sort voted first


You have to call the correctly named Add function for what you're trying to add, and as you're adding a member function, you need an object to go with it. So in this case, I assume you want to add a UObject reference to the same object that's doing the adding, so you'd use:

 TickEvent.AddUObject(this, &UCombat::FlowTowards);

See 'Binding Multi-Cast Delegates' on this page:


Hope this helps,


more ▼

answered Aug 04 '15 at 11:33 AM

avatar image

Steve Robb STAFF
2.8k 58 28 101

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


it just a guess, but in tick events float required usually for delta time, it's time passed from last tick execute, note that in case of "events" whole blueprint system is single threaded and once tick even fired, second execution won't apper until first ends

more ▼

answered Aug 04 '15 at 02:59 AM

avatar image

576 53 46 72

avatar image HInoue Aug 04 '15 at 03:02 AM

Right, but I'm not calling the event, I'm trying to register it like a delegate so when I call TickEvent(someDelta) (or whatever other event I make), every function(float somenumber) that I've registered with the event gets called. Wouldn't that mean that I wouldn't need to pass an argument to Add(), just the function's address in memory?

(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