GameplayAbility unable to activate

I’m trying to make a hack and slash single player and I recently came across gameplay abilities and thought its perfect for the type of game I’m making.

So I tried to create the initial setup that looks like this

#pragma region Abilities
	public:
		UAbilitySystemComponent * GetAbilitySystemComponent() const override;
		/** The component used to handle ability system interactions */

		UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Abilities, meta = (AllowPrivateAccess = "true")) 
		UAbilitySystemComponent* AbilitySystemComponent;

		UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Abilities)
		TSubclassOf<class UGameplayAbility> Ability;

		/** List of attributes modified by the ability system */
		UPROPERTY()
		UCharacterAttributeSet* AttributeSet;

		/** Passive gameplay effects applied on creation */
		UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Abilities")
		TArray<TSubclassOf<UGameplayEffect>> PassiveGameplayEffects;
#pragma endregion

and in beginplay of the character i did this

Super::BeginPlay();
	if (AbilitySystemComponent)
	{
		if (HasAuthority() && Ability)
		{
			AbilitySystemComponent->GiveAbility(FGameplayAbilitySpec(Ability.GetDefaultObject(), 1, 0));
		}
		AbilitySystemComponent->InitAbilityActorInfo(this, this);
	}

also in blueprints begin play of character i did this

I’m doing the same thing in both begin play of C++ and in blueprints
I get true when i call tryactivateability in blueprint but the ability is never activated.

Even the montage I mentioned in the gameplayeffect is being played but ActivateAbility is never called.

this is how the gameplay ability looks, the print is not coming but the montage i assign is playing

I do have gameplay effect assigned to ability.

259091-capture-8.png

I’m returning true in CanActivateAbility in gameplay ability.

But the control is never coming to ActivateAbility event. I dont know what i’m missing.

Thanks.

Did you receive or find an answer to this problem? I’m currently facing the same issue.

I just came across this problem today and thought i’d leave the solution around in case anyone else needed it. The problem is that if you create a child blueprint of the class “GameplayAbility_Montage” and override the ActivateAbility BP node in its graph it will never get called.

That’s due to the “Montage” subclass overriding the function ActivateAbility from its parent class “GameplayAbility”
which by default checks first if there is a custom BP node of ActivateAbility and calls it

But “GameplayAbility_Montage” instead runs its own logic of committing the ability and playing its animation and skipping the part about checking the custom BP node or calling its parent function

There are a few workarounds but if you want both the logic of playing the AnimMontage and the custom BP logic, you have to create a child class of “GameplayAbility_Montage”, override its ActivateAbility function and copy the part that checks for the custom BP node from the original “GameplayAbility” before calling the parent function of the “Montage” subclass.

Note: you could also just do this:

281659-4.png

But if you do that without any custom BP logic a branch of the original function will run and commit the ability so the cost GE will be activated twice as the Montage class commits the ability as well at the start of its function.

Hope this helps at all.

This is a great answer and important to keep in mind when overriding ActivateAbility in C++. Thank you for this.