GAS: Can't get owner/avatar in CanActivateAbility()

How come I can’t call GetAvatarActorFromActorInfo() or GetOwningActorFromActorInfo() from CanActivateAbility() for an ability that is “instanced per execution”?

If I try GetOwningActorFromActorInfo() from CanActivateAbility() I get:

LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: IsInstantiated() [File:D:\Build\++UE4\Sync\Engine\Plugins\Runtime\GameplayAbilities\Source\GameplayAbilities\Private\Abilities\GameplayAbility.cpp] [Line: 954]
LogOutputDevice: Error: Default__BP_TestAbility_C: GetOwningActorFromActorInfo can not be called on a non-instanced ability

and if I try GetAvatarActorFromActorInfo() from CanActivateAbility() I get:

LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: CurrentActorInfo [File:D:\Build\++UE4\Sync\Engine\Plugins\Runtime\GameplayAbilities\Source\GameplayAbilities\Private\Abilities\GameplayAbility.cpp] [Line: 969]

// Line 969 is checking:
if (!ensure(CurrentActorInfo))

Changing the ability to “instanced per actor” fixes the problem. But I thought that “instanced per execution” meant that it was an instanced ability since a new object is created every time the ability is executed.

I am calling InitAbilityActorInfo() in BeginPlay() and PossessedBy() and RefreshAbilityActorInfo() in OnRep_Controller().

Any idea why this wouldn’t work in CanActivateAbility() for an ability that is “instanced per execution”? Is the Owner/Avatar not set until the ability is activated for this type of ability?

2 Likes

I got a similar problem with “instanced per execution” the GetWorld() wasn’t getting a correct value. I changed my GameplayAbilities for instance per actor and now everything seems to be working fine for now. Still need to do more testing.