I am attempting to get current Anim Montage being played for an ability in the player controller using its ability spec. But it is returning null.
How do I get the current montage from a running ability elsewhere in code?
Here is the code:
void Abase_player_controller::input_action_released(Eability_action_slot action_slot)
{
if (!(CHAR && CHAR_ASC)) return;
Fability_init_properties * ability_prop_ = CHAR->get_ability_properties(action_slot);
FGameplayAbilitySpec * abil_spec_ =
CHAR_ASC->FindAbilitySpecFromClass(
ability_prop_->ability_class
);
UAnimMontage * current_anim_montage_ =
abil_spec_->
Ability->
GetCurrentMontage();
UE_LOG(
LogTemp,
Warning,
TEXT("current anim montage -> %s"),
*( (current_anim_montage_)
? current_anim_montage_->GetName()
: FString("False")
)
);
if (ability_prop_->input_action_type == Einput_action_type::held)
CHAR_ASC->CancelAbilityHandle(
CHAR_ASC->
FindAbilitySpecFromClass(ability_prop_->ability_class)->
Handle
);
// ...
}
I have also added a debugger to check the contents of the ability object in memory.
CurrentMontage property says nullptr.
However, in the blueprints, I am able to get current anim montage properly during activation.
NOTE:
I have subclassed a GA_ranged
ability from ABILITY
parent class.
Is it that I am trying to access the parent class from Ability spec?