EndAbility invoce on AbilityTask End

Hi,

I have a problem with EndAbility in my custom c++ GameplayAblility class. How can i use it on task finish?

void USPrimaryAttack_GA::ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData)
{
	Super::ActivateAbility(Handle, ActorInfo, ActivationInfo, TriggerEventData);

	UAbilityTask_PlayMontageAndWait::CreatePlayMontageAndWaitProxy(this, "Dash", DashMontage);
	//Getting current Actor velocity
	FVector DashDirection = ActorInfo->OwnerActor->GetVelocity();


	//Check if actor is moving if not get forward vector
	if (DashDirection==FVector(0, 0, 0))
	{
		DashDirection = ActorInfo->OwnerActor->GetActorForwardVector();
	}	


	//Check if we have enough resources to use ability
	if (CommitAbility(Handle,ActorInfo, ActivationInfo))
	{	
		//Set up default params
		ERootMotionFinishVelocityMode VelocityOnFinishMode = ERootMotionFinishVelocityMode::MaintainLastRootMotionVelocity;
		FVector SetVelocityOnFinish = FVector(0, 0, 0);	
		//Function that push Actor in velocity direction		
		UAbilityTask_ApplyRootMotionConstantForce::ApplyRootMotionConstantForce(this, "None", DashDirection, DashLenght, Duration, false, StrengthOverTime, VelocityOnFinishMode,
				SetVelocityOnFinish, 0.0f, false);

	}
	else
	{
		EndAbility(Handle, ActorInfo, ActivationInfo, false, false);
	}
	
}

void USPrimaryAttack_GA::EndAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, bool bReplicateEndAbility, bool bWasCancelled)
{
	Super::EndAbility(Handle, ActorInfo, ActivationInfo, bReplicateEndAbility, bWasCancelled);
	UE_LOG(LogTemp, Log, TEXT("End: %s"), *GetNameSafe(this));
}

I found a solution, ApplyRootMotionConstantForce has an OnFinish event which can be used to call the function

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.