I have a character that has implemented an ability system component. I am trying to bind a handler to the multicast delegate when any gameplay effect is removed. The goal is to have the character do something when a gameplay effect ends (cooldown in this case).
Character .h:
UFUNCTION()
void OnGameplayEffectEnd(const FActiveGameplayEffect& EndedGameplayEffect);
Character .cpp:
FOnGivenActiveGameplayEffectRemoved GameplayEffectRemovedDelegate = AbilitySystemComponent->OnAnyGameplayEffectRemovedDelegate();
GameplayEffectRemovedDelegate.AddUObject(this, &AMOBACharacter::OnGameplayEffectEnd);
However, when the cooldown is finished, OnGameplayEffectEnd is never called.
Since FOnGivenActiveGameplayEffectRemoved was not a pointer, I was inadvertently creating a new instance of this delegate instead of binding to the one that already exists on the AbilitySystemComponent. Changing the local delegate variable to a pointer and dereferencing OnAnyGameplayEffectRemovedDelegate() gave me what I needed.