1

To get notified about the reason why a GameplayAbility failed to activate, it is possible to assign a function to the delegate UAbilitySystemComponent::AbilityFailedCallbacks(). It contains a tag parameter. This parameter can be used to determine the reason why UAbilitySystemComponent::TryActivateAbility() failed, be it either:

  • the ability is on cooldown
  • the cost couldn’t be afforded
  • blocked by other abilities
  • the AbilitySystemComponent is missing required GameplayTags

However, when testing, the tag in the delegate is empty (or the delegate isn't even fired).

  1. Where does this tag come from?
  2. How to set that tag?
Roi Danton
  • 7,933
  • 6
  • 68
  • 80

1 Answers1

1

(1) Those tags are part of UAbilitySystemGlobals. It has tags for:

  • actor is being dead ActivateFailIsDeadTag
  • on cooldown ActivateFailCooldownTag
  • insufficient costs ActivateFailCostTag
  • blocked by other abilities ActivateFailTagsBlockedTag
  • missing required tags ActivateFailTagsMissingTag
  • invalid networking settings ActivateFailNetworkingTag

(2) They can be set by (example for cost)

  1. Set the tags in DefaultGame.ini, using the corresponding FName (example for costs):

    [/Script/GameplayAbilities.AbilitySystemGlobals]
    ActivateFailCostName=My.Test.Tag
    
  2. Make sure, the GameplayTag exists, e.g. in DefaultGameplayTags.ini

    +GameplayTagList=(Tag="My.Test.Tag",DevComment="")
    
  3. Initialize those tags by calling UAbilitySystemGlobals::Get().InitGlobalData(), e.g. in the constructor of your UGameInstance subclass.

How does that work

Example for costs:

in UGameplayAbility::CanActivateAbility() -> UGameplayAbility::CheckCost():

  • UAbilitySystemGlobals::ActivateFailCostTag is applied to optional out param OptionalRelevantTags if costs can’t be afforded
  • this tag is used in UAbilitySystemComponent::NotifyAbilityFailed() which
  • fires the delegate UAbilitySystemComponent::AbilityFailedCallbacks

This is similar for the other cases mentioned above (cooldown, block, …).

Roi Danton
  • 7,933
  • 6
  • 68
  • 80