I’m going through the pseudo-tutorial at Events | Unreal Engine Documentation , 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(){
TickEvent.Add(&UCombat::FlowTowards);
}
“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)