Javiere
(Javiere)
June 14, 2017, 2:46pm
83
For a list of all current effects you can query the tags on that player. If you’re finding you need to do this a lot then I think you should step back for a minute and think about whether you can do it in a more modular way. I have a lot of status effects in a fairly standard dungeon crawler and the only time I iterate over all the tags/effects is when I’m debugging.
For time remaining of effects you can use one of several methods like:
[FONT=Courier New]
TArray<float> GetActiveEffectsTimeRemaining(const FGameplayEffectQuery& Query) const;
but this method isn’t exposed to blueprint and for HUD icons of status effects (like slow or burning or whatever) you might be want to put it in the cue.
since cooldowns are effects, you can use the same system to get time remaining for cooldowns. There is a convenience method
[FONT=Courier New]
UFUNCTION(BlueprintCallable, Category = Ability)
float GetCooldownTimeRemaining() const;
I configured a GameplayAbility with a GameplayEffect as cooldown. It’s working well but now I want to get the cooldown time to show on the UI.
I am trying to use the function GetCooldownTimeRemaining() but it always returns 0. To get the UGameplayAbility I use this:
FGameplayAbilitySpec* AbilitySpec = AbilitySystem->FindAbilitySpecFromClass(Ability);
if (AbilitySpec && AbilitySpec->Ability)
{
float TimeRemaining = AbilitySpec->Ability->GetCooldownTimeRemaining();
UE_LOG(LogTemp, Warning, TEXT("Time Remaining %f"), TimeRemaining);
}
I assume that this is incorrect. How I obtain the GameplayAbility correctly to get the cooldown?