AAIController

AIController is the base class of controllers for AI-controlled Pawns.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

AIModule

Header

/Engine/Source/Runtime/AIModule/Classes/AIController.h

Include

#include "AIController.h"

Syntax

class AAIController :
    public AController,
    public IAIPerceptionListenerInterface,
    public IGameplayTaskOwnerInterface,
    public IGenericTeamAgentInterface,
    public IVisualLoggerDebugSnapshotInterface

Remarks

AIController is the base class of controllers for AI-controlled Pawns.

Controllers are non-physical actors that can be attached to a pawn to control its actions. AIControllers manage the artificial intelligence for the pawns they control. In networked games, they only exist on the server.

Variables

Name Description

Public variable

uint32: 1

 

bAllowStrafe

Is strafing allowed during movement?

Protected variable

UBlackboardComp...

 

Blackboard

Blackboard

Public variable

uint32: 1

 

bLOSflag

Used for alternating LineOfSight traces

Public variable

UBrainComponent...

 

BrainComponent

Component responsible for behaviors.

Public variable

uint32: 1

 

bSetControlRotationFromPawnOrientation

Copy Pawn rotation to ControlRotation, if there is no focus point.

Public variable

uint32: 1

 

bSkipExtraLOSChecks

Skip extra line of sight traces to extremities of target being checked.

Protected variable

uint32: 1

 

bStartAILogicOnPossess

By default AI's logic does not start when controlled Pawn is possessed.

Protected variable

uint32: 1

 

bStopAILogicOnUnposses

By default AI's logic gets stopped when controlled Pawn is unpossessed.

Public variable

uint32: 1

 

bWantsPlayerState

Specifies if this AI wants its own PlayerState.

Protected variable

UGameplayTasksC...

 

CachedGameplayTasksComponent

Protected variable

TSubclassOf< UN...

 

DefaultNavigationFilterClass

Protected variable

FFocusKnowledge

 

FocusInformation

Public variable

UAIPerceptionCo...

 

PerceptionComponent

Public variable

FAIMoveComplete...

 

ReceiveMoveCompleted

Blueprint notification that we've completed the current movement request

Constructors

Name Description

Public function

AAIController

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function Virtual

void

 

ActorsPerceptionUpdated

(
    const TArray< AActor* >& Upda...
)

Notifies AIController of changes in given actors' perception

Public function Static

bool

 

AreAIIgnoringPlayers()

Public function Const

bool

 

BuildPathfindingQuery

(
    const FAIMoveRequest& MoveRequest,
    FPathFindingQuery& Query
)

Helper function for creating pathfinding query for this agent from move request data

Public function

void

 

ClaimTaskResource

Public function Virtual

void

 

ClearFocus

(
    EAIFocusPriority::Type InPriority
)

Clears Focus for given priority, will also clear FocalPoint as a result

Public function Virtual Const

void

 

FindPathForMoveRequest

(
    const FAIMoveRequest& MoveRequest,
    FPathFindingQuery& Query,
    FNavPathSharedPtr& OutPath
)

Finds path for given move request

Public function Const

UPawnActions...

 

GetActionsComp()

Returns ActionsComp subobject

Public function Const

const UAIPer...

 

GetAIPerceptionComponent()

Public function

UAIPerceptio...

 

GetAIPerceptionComponent()

Public function

UBlackboardC...

 

GetBlackboardComponent()

Public function Const

const UBlack...

 

GetBlackboardComponent()

Public function Const

UBrainCompon...

 

GetBrainComponent()

Public function Const

FAIRequestID

 

GetCurrentMoveRequestID()

Returns the Move Request ID for the current move

Public function Virtual Const

FString

 

GetDebugIcon()

Debug/dev-time

Public function Const

TSubclassOf<...

 

GetDefaultNavigationFilterClass()

Public function Const

FVector

 

GetFocalPoint()

Retrieve the final position that controller should be looking at.

Public function Const

FVector

 

GetFocalPointForPriority

(
    EAIFocusPriority::Type InPriority
)

Public function Virtual Const

FVector

 

GetFocalPointOnActor

(
    const AActor* Actor
)

Retrieve the focal point this controller should focus to on given actor.

Public function Const

AActor *

 

GetFocusActor()

Get the focused actor.

Public function Const

AActor *

 

GetFocusActorForPriority

(
    EAIFocusPriority::Type InPriority
)

Public function Const

UGameplayTas...

 

GetGameplayTasksComponent()

Public function Const

FVector

 

GetImmediateMoveDestination()

Returns position of current path segment's end.

Public function Const

EPathFollowi...

 

GetMoveStatus()

Returns status of path following

Public function Const

UPathFollowi...

 

GetPathFollowingComponent()

Returns PathFollowingComponent subobject

Public function Const

bool

 

HasPartialPath()

Returns true if the current PathFollowingComponent's path is partial (does not reach desired destination).

Protected function Virtual

bool

 

InitializeBlackboard

(
    UBlackboardComponent& BlackboardCo...,
    UBlackboardData& BlackboardAsset
)

Public function

void

 

K2_ClearFocus()

Clears Focus, will also clear FocalPoint as a result

Public function

void

 

K2_SetFocalPoint

(
    FVector FP
)

Set the position that controller should be looking at.

Public function

void

 

K2_SetFocus

(
    AActor* NewFocus
)

Set Focus for actor, will set FocalPoint as a result.

Public function Virtual Const

bool

 

LineOfSightTo

(
    const AActor* Other,
    FVector ViewPoint,
    bool bAlternateChecks
)

Checks line to center and top of other actor

Public function Virtual

FPathFollowi...

 

MoveTo

(
    const FAIMoveRequest& MoveRequest,
    FNavPathSharedPtr* OutPath
)

Makes AI go toward specified destination

Public function

EPathFollowi...

 

MoveToActor

(
    AActor* Goal,
    float AcceptanceRadius,
    bool bStopOnOverlap,
    bool bUsePathfinding,
    bool bCanStrafe,
    TSubclassOf< UNavigationQueryFilter...,
    bool bAllowPartialPath
)

Makes AI go toward specified Goal actor (destination will be continuously updated), aborts any active path following

Public function

EPathFollowi...

 

MoveToLocation

(
    const FVector& Dest,
    float AcceptanceRadius,
    bool bStopOnOverlap,
    bool bUsePathfinding,
    bool bProjectDestinationToNavigatio...,
    bool bCanStrafe,
    TSubclassOf< UNavigationQueryFilter...,
    bool bAllowPartialPath
)

Makes AI go toward specified Dest location, aborts any active path following

Public function Virtual

void

 

OnGameplayTaskResourcesClaimed

(
    FGameplayResourceSet NewlyClaimed,
    FGameplayResourceSet FreshlyRelease...
)

Public function Virtual

void

 

OnMoveCompleted

(
    FAIRequestID RequestID,
    EPathFollowingResult::Type Result
)

Public function Virtual

void

 

OnMoveCompleted

(
    FAIRequestID RequestID,
    const FPathFollowingResult& Result
)

Called on completing current movement request

Protected function

void

 

OnUsingBlackBoard

(
    UBlackboardComponent* Blackboa...,
    UBlackboardData* BlackboardAss...
)

Public function

bool

 

PauseMove

(
    FAIRequestID RequestToPause
)

If AI is currently moving due to request given by RequestToPause, then the move will be paused

Public function

bool

 

PerformAction

(
    UPawnAction& Action,
    EAIRequestPriority::Type Priority,
    UObject*const Instigator
)

Actions.

Public function Virtual

bool

 

PreparePathfinding

(
    const FAIMoveRequest& MoveRequest,
    FPathFindingQuery& Query
)

Public function Virtual

FAIRequestID

 

RequestMove

(
    const FAIMoveRequest& MoveRequest,
    FNavPathSharedPtr Path
)

Passes move request and path object to path following

Public function Virtual

FAIRequestID

 

RequestPathAndMove

(
    const FAIMoveRequest& MoveRequest,
    FPathFindingQuery& Query
)

Public function

bool

 

ResumeMove

(
    FAIRequestID RequestToResume
)

Resumes last AI-performed, paused request provided it's ID was equivalent to RequestToResume

Public function Virtual

bool

 

RunBehaviorTree

(
    UBehaviorTree* BTAsset
)

Starts executing behavior tree.

Public function Virtual

void

 

SetFocalPoint

(
    FVector NewFocus,
    EAIFocusPriority::Type InPriority
)

Set FocalPoint for given priority as absolute position or offset from base.

Public function Virtual

void

 

SetFocus

(
    AActor* NewFocus,
    EAIFocusPriority::Type InPriority
)

Set Focus actor for given priority, will set FocalPoint as a result.

Public function

void

 

SetMoveBlockDetection

(
    bool bEnable
)

Updates state of movement block detection.

Public function

void

 

SetPathFollowingComponent

(
    UPathFollowingComponent* NewPF...
)

That his function does not do any pathfollowing state transfer.

Public function

void

 

SetPerceptionComponent

(
    UAIPerceptionComponent& InPercepti...
)

Public function Virtual Const

bool

 

ShouldSyncBlackboardWith

(
    const UBlackboardComponent& OtherB...
)

Does this AIController allow given UBlackboardComponent sync data with it

Public function

bool

 

SuggestTossVelocity

(
    FVector& OutTossVelocity,
    FVector Start,
    FVector End,
    float TossSpeed,
    bool bPreferHighArc,
    float CollisionRadius,
    bool bOnlyTraceUp
)

Computes a launch velocity vector to toss a projectile and hit the given destination.

Public function Static

void

 

ToggleAIIgnorePlayers()

Cheat/debugging functions.

Public function

void

 

UnclaimTaskResource

Public function Virtual

void

 

UpdateControlRotation

(
    float DeltaTime,
    bool bUpdatePawn
)

Update direction AI is looking based on FocalPoint

Public function

bool

 

UseBlackboard

(
    UBlackboardData* BlackboardAss...,
    UBlackboardComponent*& Blackbo...
)

Makes AI use the specified Blackboard asset & creates a Blackboard Component if one does not already exist.

Overridden from AController

Name Description

Public function Virtual

void

 

DisplayDebug

(
    UCanvas* Canvas,
    const FDebugDisplayInfo& DebugDisp...,
    float& YL,
    float& YPos
)

Protected function Virtual

void

 

OnPossess

(
    APawn* InPawn
)

Overridable native function for when this controller is asked to possess a pawn.

Protected function Virtual

void

 

OnUnPossess()

Overridable native function for when this controller unpossesses its pawn.

Public function Virtual

void

 

SetPawn

(
    APawn* InPawn
)

Setter for Pawn. Normally should only be used internally when possessing/unpossessing a Pawn.

Public function Virtual

void

 

StopMovement()

Aborts the move the controller is currently performing

Overridden from AActor

Name Description

Public function Virtual

void

 

PostInitializeComponents()

Overridden to create the player replication info and perform other mundane initialization tasks.

Public function Virtual

void

 

PostRegisterAllComponents()

Called after all the components in the Components array are registered, called both in editor and during gameplay

Public function Virtual

void

 

Reset()

Reset actor to initial state - used when restarting level without reloading.

Public function Virtual

void

 

Tick

(
    float DeltaSeconds
)

Function called every frame on this Actor.

Overridden from INavAgentInterface

Name Description

Public function Virtual Const

IPathFollowi...

 

GetPathFollowingAgent()

Retrieves PathFollowingAgent for this NavAgent

Public function Virtual Const

bool

 

IsFollowingAPath()

Checks if the agent is actively following a navigation path

Public function Virtual Const

bool

 

ShouldPostponePathUpdates()

Allows delaying repath requests

Overridden from IAIPerceptionListenerInterface

Name Description

Public function Virtual

UAIPerceptio...

 

GetPerceptionComponent()

Overridden from IGameplayTaskOwnerInterface

Name Description

Public function Virtual Const

AActor *

 

GetGameplayTaskAvatar

(
    const UGameplayTask* Task
)

Get "body" of task's owner / default, having location in world (e.g. Owner = AIController, Avatar = Pawn)

Public function Virtual Const

uint8

 

GetGameplayTaskDefaultPriority()

Get default priority for running a task

Public function Virtual Const

AActor *

 

GetGameplayTaskOwner

(
    const UGameplayTask* Task
)

Get owner of a task or default one when task is null

Public function Virtual Const

UGameplayTas...

 

GetGameplayTasksComponent

(
    const UGameplayTask& Task
)

Finds tasks component for given GameplayTask, Task.GetGameplayTasksComponent() may not be initialized at this point!

Public function Virtual

void

 

OnGameplayTaskActivated

(
    UGameplayTask& Task
)

Notify called after GameplayTask changes state to Active (initial activation or resuming)

Public function Virtual

void

 

OnGameplayTaskDeactivated

(
    UGameplayTask& Task
)

Notify called after GameplayTask changes state from Active (finishing or pausing)

Public function Virtual

void

 

OnGameplayTaskInitialized

(
    UGameplayTask& Task
)

Add empty overrides to fix linker errors if project implements a child class without adding GameplayTasks module dependency

Overridden from IGenericTeamAgentInterface

Name Description

Public function Virtual Const

FGenericTeam...

 

GetGenericTeamId()

Retrieve team identifier in form of FGenericTeamId

Public function Virtual

void

 

SetGenericTeamId

(
    const FGenericTeamId& TeamID
)

Assigns Team Agent to given TeamID

Overridden from IVisualLoggerDebugSnapshotInterface

Name Description

Public function Virtual Const

void

 

GrabDebugSnapshot

(
    FVisualLogEntry* Snapshot
)

Constants

Name

Description

bAIIgnorePlayers

If true, AI controllers will ignore players.

See Also

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss