RealDocs

UBTTaskNode::OnGameplayTaskDeactivated

function AIModule Since 4.0
#include "BehaviorTree/BTTaskNode.h"
Access: public Specifiers: virtualoverride

Description

Called by the gameplay task system when a UGameplayTask owned by this behavior tree task deactivates, allowing the BT task to react and potentially finish itself.

Caveats & Gotchas

  • Only relevant if the BT task drives a UGameplayTask internally (e.g. via a gameplay task component); tasks that don't use gameplay tasks never see this called.
  • This is a UBTNode/UGameplayTaskOwnerInterface override, not something invoked by the behavior tree scheduler directly.
  • Must handle the case where the gameplay task deactivates for reasons other than success, such as being externally cancelled.

Signature

virtual void OnGameplayTaskDeactivated(UGameplayTask& Task) override;

Parameters

Name Type Description Default
Task UGameplayTask& The gameplay task that just deactivated.

Return Type

void

Example

React to an owned gameplay task ending C++
void UMyTask::OnGameplayTaskDeactivated(UGameplayTask& Task)
{
	Super::OnGameplayTaskDeactivated(Task);
	// Inspect Task.GetState() and finish the BT task accordingly
}

Tags

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.