Hi, an ability I created is not activated, TryActivateGameplayAbilityByClass returns false and nothing happens. Another ability, in another blueprint, worked as intended, however, this new ability always fails and I do not know why. I am trying to figure out why this is the case, and for this I wanted to bind the
FAbilityFailedDelegate AbilityFailedCallbacks;
delegate, which is defined in the UAbilitySystemComponent to a simple function in one of my classes to inspect the GameplayTags it returns which return information about the cause of error.
This is the class of which I want to bind a function to the delegate
UCLASS(ClassGroup = "RTS", Category = "RTS")
class REALTIMESTRATEGY_API URTSCombatComponent : public UAbilitySystemComponent, public IRTSGameplayTagsProvider
{
as you can see, it inherits from the AbilitySystemComponent. In URTSCombatComponent, I declared
UFUNCTION()
void StoreAbilityFail(const UGameplayAbility* Ability, const FGameplayTagContainer& GameplayTags);
which currently just does
void URTSCombatComponent::StoreAbilityFail(const UGameplayAbility* Ability, const FGameplayTagContainer& GameplayTags)
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("ABILITY DELEGATE CALLED")));
}
to see if it was correctly bound. The binding is done in the constructor of the URTSCombatComponent:
URTSCombatComponent::URTSCombatComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
this->AbilityFailedCallbacks.AddUObject(this, &URTSCombatComponent::StoreAbilityFail);
}
The class, and the game, compiles fine. However, TryActivateGameplayAbility returns false, yet, StoreAbilityFail is not called, I do not see a debug message. Am I binding it incorrectly? Any suggestion is welcomed, it is difficult to debug without rebuilding the entire unreal engine.
edit: I realized I should bind the function inside the BeginPlay function. However, the result is the same.