How to use LandedDelegate and already existing events in general in C++?

Hello everyone,

I have a question concerning the LandedDelegate : AddDynamichttps://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/GameFramework/ACharacter/LandedDelegate/

Basically I want to trigger an event (change the value of a variable inside my class) when this event fires. However I have found nothing on how to use delegate for already existing event. Tutorials online are mostly about how to create your own delegate and event. The closer I could get are tutorial about BeginOverlap event but it looks totally different and the lack of domentation doesn’t help.

I already tried to create UPROPERTY FLandedSignature OnPlayerLand; but when I try to add the triggered function like this OnPlayerLand.AddDynamic(this, &AMyCharacter::RespondToLanded); I get an error message saying "This conversion requires a reinterpret_cast, a C-style cast or function-style cast

Any help would be appreciated, thank you.

Just override the function in your class and it’ll work:

.h:
void Landed(const FHitResult& Hit) override;

.cpp:

void AMyClass::Landed(const FHitResult& Hit)
{
    Super::Landed(Hit);
    // Your Stuff Goes Here
}

You mean I don’t need to use AddDynamic at all ? So each time I want to trigger something based on an already exising event I just need to override the function ?

If the function is virtual, yes, just override it and that’s it. Don’t forget to call Super:: function on overridden; otherwise some of them may not work correctly.

You are a life saver, spent all the afternoon trying to make this work. Thank you very much !

1 Like