Hello, Im using the Lyra framework for my Unreal Engine game. I have a UActorComponent attached to my PlayerCharacter, which is derived from ALyraCharacter. The question is: When I trigger my LyraGameplayAbility, I want to call an event dispatcher, which the UActorComponent on my player should bind too. I dont know how to get a reference to my LyraGameplayAbility from within my UActorComponent, so i can bind to its event dispatcher. any help would be appreciated!
Thank you!
You could do it through the ability system instead, so your ability broadcasts and event on the ability system, and your actor component can bind to that one generic event
Otherwise, in Lyra there is also the gameplay messaging subsystem, so you can broadcast generic events and listen to them anywhere
In C++ it would be something like:
// In ActivateAbility
FGameplayTag MessageTag;
FMyStruct MessageStruct;
UGameplayMessageSubsystem::Get(this).BroadcastMessage(MessageTag, MessageStruct);
...
// In the component class:
void MyEventReactingFunction(FGameplayTag MessageTag, FMyStruct MessageStruct);
...
UGameplayMessageSubsystem::Get(this).RegisterListener(MessageTag, this, &ThisClas::MyEventReactingFunction);