RealDocs

AAIController::OnGameplayTaskDeactivated

function AIModule Since 4.12
#include "AIController.h"
Access: public Specifiers: virtualoverride

Description

Called when a gameplay task owned by this controller transitions out of the active state, either because it finished, was paused, or was cancelled. The base implementation is empty.

Caveats & Gotchas

  • This is called for both task completion and task pausing — check `Task.IsFinished()` if you need to distinguish between the two cases.
  • Clearing a cached task pointer here is safe, but do not access the task after calling `EndTask()` inside this callback, as the task object may be destroyed depending on its lifetime settings.

Signature

virtual void OnGameplayTaskDeactivated(UGameplayTask& Task) override {}

Parameters

Name Type Description Default
Task UGameplayTask& The task that has just become inactive.

Return Type

void

Example

Clean up cached task reference C++
void AMyAIController::OnGameplayTaskDeactivated(UGameplayTask& Task)
{
	Super::OnGameplayTaskDeactivated(Task);
	if (ActiveTask == &Task)
	{
		ActiveTask = nullptr;
	}
}

Version History

Introduced in: 4.12

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.