AAIController::GetGameplayTaskOwner
#include "AIController.h"
Access: public
Specifiers: virtualconstoverride
Description
Returns the actor that owns the gameplay task — always the AI controller itself. This is the IGameplayTaskOwnerInterface implementation that ties tasks to the controller.
Caveats & Gotchas
- • Returns `const_cast<AAIController*>(this)`, so the returned pointer is the controller, not the possessed pawn. Tasks that need to affect the pawn should call `GetGameplayTaskAvatar` instead.
- • This is an engine-internal interface method. You should not call it directly; it is called by the GameplayTasks component when a task needs to resolve its owner.
Signature
virtual AActor* GetGameplayTaskOwner(const UGameplayTask* Task) const override { return const_cast<AAIController*>(this); } Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Task | const UGameplayTask* | The gameplay task querying its owner. | — |
Return Type
AActor* Example
Override to redirect task ownership to a pawn subobject C++
// If you want tasks to consider the pawn as the owner instead of the controller:
AActor* AMyAIController::GetGameplayTaskOwner(const UGameplayTask* Task) const
{
return GetPawn() ? GetPawn() : Super::GetGameplayTaskOwner(Task);
} See Also
Tags
Version History
Introduced in: 4.12
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?