How to Bind to Gameplay Effect Delegates From AbilitySystemComponent?

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:
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.

What am I doing wrong?


The .cpp section is during BeginPlay(), by the way.

Figured it out.

FOnGivenActiveGameplayEffectRemoved* GameplayEffectRemovedDelegate = &AbilitySystemComponent->OnAnyGameplayEffectRemovedDelegate();
GameplayEffectRemovedDelegate->AddUObject(this, &AMOBACharacter::OnGameplayEffectEnd);

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.