Language:
Discover
By Skill Level
By Category

AAIController

Choose your OS:

Inheritance Hierarchy

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

 

bStopAILogicOnUnposses

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

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

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

void

 

FindPathForMoveRequest

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

Finds path for given move request

Public function

UPawnActions ...

 

GetActionsComp()

Returns ActionsComp subobject

Public function

const UAIPer ...

 

GetAIPerceptionComponent()

Public function

UAIPerceptio ...

 

GetAIPerceptionComponent()

Public function

UBlackboardC ...

 

GetBlackboardComponent()

Public function

const UBlack ...

 

GetBlackboardComponent()

Public function

UBrainCompon ...

 

GetBrainComponent()

Public function

FAIRequestID

 

GetCurrentMoveRequestID()

Returns the Move Request ID for the current move

Public function Virtual

FString

 

GetDebugIcon()

-------------------------------------------------------------------// debug/dev-time -------------------------------------------------------------------//

Public function

TSubclassOf <...

 

GetDefaultNavigationFilterClass()

Public function

FVector

 

GetFocalPoint()

Retrieve the final position that controller should be looking at.

Public function

FVector

 

GetFocalPointForPriority

(
    EAIFocusPriority::Type InPriority
)

Public function Virtual

FVector

 

GetFocalPointOnActor

(
    const AActor * Actor
)

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

Public function

AActor *

 

GetFocusActor()

Get the focused actor.

Public function

AActor *

 

GetFocusActorForPriority

(
    EAIFocusPriority::Type InPriority
)

Public function

UGameplayTas ...

 

GetGameplayTasksComponent()

Public function

FVector

 

GetImmediateMoveDestination()

Returns position of current path segment's end.

Public function

EPathFollowi ...

 

GetMoveStatus()

Returns status of path following

Public function

UPathFollowi ...

 

GetPathFollowingComponent()

Returns PathFollowingComponent subobject

Public function

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

bool

 

LineOfSightTo

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

Checks line to center and top of other actor

true if controller's pawn can see Other actor.

Public function Virtual

FPathFollowi ...

 

MoveTo

(
    const FAIMoveRequest & MoveRequest,
    FNavPathSharedPtr * OutPath
)

Makes AI go toward specified destination

struct holding MoveId and enum code

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

Public function

void

 

OnPossess

(
    APawn * PossessedPawn
)

Event called when PossessedPawn is possessed by this controller.

Public function

void

 

OnUnpossess

(
    APawn * UnpossessedPawn
)

Gets triggered after given pawn has been unpossesed

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
)

DEPRECATED FUNCTION SUPPORT.

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
)

DEPRECATED FUNCTION SUPPORT.

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
)

ENABLE_VISUAL_LOG.

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...
)

Note that his function does not do any pathfollowing state transfer.

Public function

void

 

SetPerceptionComponent

(
    UAIPerceptionComponent & InPercepti...
)

Public function Virtual

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
)

Public function Virtual

void

 

Possess

(
    APawn * InPawn
)

Handles attaching this controller to the specified 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

Public function Virtual

void

 

UnPossess()

Called to unpossess our pawn for any reason that is not the pawn being destroyed (destruction handled by PawnDestroyed()).

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

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

IPathFollowi ...

 

GetPathFollowingAgent()

Retrieves PathFollowingAgent for this NavAgent

Public function Virtual

bool

 

IsFollowingAPath()

-------------------------------------------------------------------// INavAgentInterface -------------------------------------------------------------------//

Public function Virtual

bool

 

ShouldPostponePathUpdates()

Allows delaying repath requests

Overridden from IAIPerceptionListenerInterface

Name Description

Public function Virtual

UAIPerceptio ...

 

GetPerceptionComponent()

-------------------------------------------------------------------// IAIPerceptionListenerInterface -------------------------------------------------------------------//

Overridden from IGameplayTaskOwnerInterface

Name Description

Public function Virtual

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

uint8

 

GetGameplayTaskDefaultPriority()

Get default priority for running a task

Public function Virtual

AActor *

 

GetGameplayTaskOwner

(
    const UGameplayTask * Task
)

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

Public function Virtual

UGameplayTas ...

 

GetGameplayTasksComponent

(
    const UGameplayTask & Task
)

-------------------------------------------------------------------// IGameplayTaskOwnerInterface -------------------------------------------------------------------//

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

FGenericTeam ...

 

GetGenericTeamId()

Retrieve team identifier in form of FGenericTeamId

Public function Virtual

void

 

SetGenericTeamId

(
    const FGenericTeamId & NewTeamID
)

----------------------------------------------------------------// IGenericTeamAgentInterface ----------------------------------------------------------------//

Overridden from IVisualLoggerDebugSnapshotInterface

Name Description

Public function Virtual

void

 

GrabDebugSnapshot

(
    FVisualLogEntry * Snapshot
)

Constants

Name

Description

bAIIgnorePlayers

If true, AI controllers will ignore players.

See Also

References

Module

AIModule

Header

Runtime/AIModule/Classes/AIController.h