Language:
Discover
By Skill Level
By Category

AController

Choose your OS:

Inheritance Hierarchy

Syntax

class AController :
    public AActor ,
    public INavAgentInterface

Remarks

Controllers are non-physical actors that can possess a Pawn to control its actions. PlayerControllers are used by human players to control pawns, while AIControllers implement the artificial intelligence for the pawns they control. Controllers take control of a pawn using their Possess() method, and relinquish control of the pawn by calling UnPossess() .

Controllers receive notifications for many of the events occurring for the Pawn they are controlling. This gives the controller the opportunity to implement the behavior in response to this event, intercepting the event and superseding the Pawn's default behavior.

ControlRotation (accessed via GetControlRotation() ), determines the viewing/aiming direction of the controlled Pawn and is affected by input such as from a mouse or gamepad.

Variables

Name Description

Protected variable

uint32 : 1

 

bAttachToPawn

If true, the controller location will match the possessed Pawn's location.

Protected variable

uint32 : 1

 

bIsPlayerController

Whether this controller is a PlayerController.

Protected variable

FRotator

 

ControlRotation

The control rotation of the Controller. See GetControlRotation.

Protected variable

uint8

 

IgnoreLookInput

Ignores look input.

Protected variable

uint8

 

IgnoreMoveInput

Ignores movement input.

Public variable

FInstigatedAnyD ...

 

OnInstigatedAnyDamage

Called when the controller has instigated damage in any way

Protected variable

FPawnChangedSig ...

 

OnNewPawn

Public variable

APlayerState &#...

 

PlayerState

PlayerState containing replicated information about the player using this controller (only exists for players, not NPCs).

Public variable

TWeakObjectPtr <...

 

StartSpot

Actor marking where this controller spawned in.

Public variable

FName

 

StateName

Current gameplay state this controller is in

Constructors

Name Description

Public function

AController

(
    const FObjectInitializer & ObjectIn...
)

Default Constructor

Functions

Name Description

Protected function Virtual

void

 

AddPawnTickDependency

(
    APawn * NewPawn
)

Add dependency that makes us tick before the given Pawn.

Protected function Virtual

void

 

AttachToPawn

(
    APawn * InPawn
)

Physically attach the Controller to the specified Pawn, so that our position reflects theirs.

Protected function Virtual

void

 

BeginInactiveState()

State entered when inactive (no possessed pawn, not spectating, etc).

Public function

APlayerContr ...

 

CastToPlayerController()

DEPRECATED! Use the standard "Cast To" node instead.

Public function Virtual

void

 

ChangeState

(
    FName NewState
)

Change the current state to named state

Public function Virtual

void

 

CleanupPlayerState()

Called from Destroyed() .

Public function

void

 

ClientSetLocation

(
    FVector NewLocation,
    FRotator NewRotation
)

Replicated function to set the pawn location and rotation, allowing server to force (ex. teleports).

Public function

void

 

ClientSetRotation

(
    FRotator NewRotation,
    bool bResetCamera
)

Replicated function to set the pawn rotation, allowing the server to force.

Public function Virtual

void

 

CurrentLevelUnloaded()

Called when the level this controller is in is unloaded via streaming.

Protected function Virtual

void

 

DetachFromPawn()

Detach the RootComponent from its parent, but only if bAttachToPawn is true and it was attached to a Pawn.

Public function Virtual

void

 

DisplayDebug

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

Protected function Virtual

void

 

EndInactiveState()

Called when leaving the inactive state

Public function Virtual

void

 

FailedToSpawnPawn()

GameMode failed to spawn pawn for me.

Public function Virtual

void

 

GameHasEnded

(
    AActor * EndGameFocus,
    bool bIsWinner
)

Called from game mode upon end of the game, used to transition to proper state.

Public function

ACharacter &...

 

GetCharacter()

Getter for Character

Public function Virtual

FRotator

 

GetControlRotation()

Get the control rotation.

Public function Virtual

FRotator

 

GetDesiredRotation()

Get the desired pawn target rotation

Public function

FPawnChanged ...

 

GetOnNewPawnNotifier()

Public function

APawn *

 

GetPawn()

Getter for Pawn

Public function

T *

 

GetPlayerState()

This controller's PlayerState cast to the template type, or NULL if there is not one.

Public function Virtual

void

 

GetPlayerViewPoint

(
    FVector & Location,
    FRotator & Rotation
)

Returns Player's Point of View For the AI this means the Pawn's 'Eyes' ViewPoint For a Human player, this means the Camera's ViewPoint

Public function

FName

 

GetStateName()

The name of the current state

Protected function

USceneCompon ...

 

GetTransformComponent()

Returns TransformComponent subobject

Public function Virtual

AActor *

 

GetViewTarget()

Get the actor the controller is looking at

Public function Virtual

void

 

InitNavigationControl

(
    UObject *& PathFollowingComp
)

Prepares path following component

Public function Virtual

void

 

InitPlayerState()

Spawns and initializes the PlayerState for this Controller

Public function Virtual

void

 

InstigatedAnyDamage

(
    float Damage,
    const UDamageType * DamageType,
    AActor * DamagedActor,
    AActor * DamageCauser
)

Called when this controller instigates ANY damage

Public function

bool

 

IsInState

(
    FName InStateName
)

States (uses FNames for replication, correlated to state flags)

Public function Virtual

bool

 

IsLocalController()

Returns whether this Controller is a local controller.

Public function

bool

 

IsLocalPlayerController()

Returns whether this Controller is a locally controlled PlayerController.

Public function Virtual

bool

 

IsLookInputIgnored()

Returns true if look input is ignored.

Public function Virtual

bool

 

IsMoveInputIgnored()

Returns true if movement input is ignored.

Public function

bool

 

IsPlayerController()

INLINES.

Public function

APawn *

 

K2_GetPawn()

Return the Pawn that is currently 'controlled' by this PlayerController

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

void

 

OnRep_Pawn()

Replication Notification Callbacks

Public function Virtual

void

 

OnRep_PlayerState()

Public function Virtual

void

 

PawnPendingDestroy

(
    APawn * inPawn
)

Called to unpossess our pawn because it is going to be destroyed.

Public function Virtual

void

 

Possess

(
    APawn * InPawn
)

Handles attaching this controller to the specified pawn.

Protected function

void

 

ReceiveInstigatedAnyDamage

(
    float Damage,
    const UDamageType * DamageType,
    AActor * DamagedActor,
    AActor * DamageCauser
)

Event when this controller instigates ANY damage

Protected function Virtual

void

 

RemovePawnTickDependency

(
    APawn * InOldPawn
)

Remove dependency that makes us tick before the given Pawn.

Public function Virtual

void

 

ResetIgnoreInputFlags()

Reset move and look input ignore flags.

Public function Virtual

void

 

ResetIgnoreLookInput()

Stops ignoring look input by resetting the ignore look input state.

Public function Virtual

void

 

ResetIgnoreMoveInput()

Stops ignoring move input by resetting the ignore move input state.

Public function Virtual

void

 

SetControlRotation

(
    const FRotator & NewRotation
)

Set the control rotation.

Public function Virtual

void

 

SetIgnoreLookInput

(
    bool bNewLookInput
)

Locks or unlocks look input, consecutive calls stack up and require the same amount of calls to undo, or can all be undone using ResetIgnoreLookInput.

Public function Virtual

void

 

SetIgnoreMoveInput

(
    bool bNewMoveInput
)

Locks or unlocks movement input, consecutive calls stack up and require the same amount of calls to undo, or can all be undone using ResetIgnoreMoveInput.

Public function Virtual

void

 

SetInitialLocationAndRotation

(
    const FVector & NewLocation,
    const FRotator & NewRotation
)

Set the initial location and rotation of the controller, as well as the control rotation.

Public function Virtual

void

 

SetPawn

(
    APawn * InPawn
)

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

Public function

void

 

SetPawnFromRep

(
    APawn * InPawn
)

Calls SetPawn and RepNotify locally

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

Public function Virtual

void

 

UpdateNavigationComponents()

If controller has any navigation-related components then this function makes them update their cached data DEPRECATED: this functionality has been taken over by PathFollowingComponent by observing newly possessed pawns (via OnNewPawn)

Overridden from AActor

Name Description

Public function Virtual

void

 

Destroyed()

Called once this actor has been deleted

Public function Virtual

void

 

GetActorEyesViewPoint

(
    FVector & OutLocation,
    FRotator & OutRotation
)

Returns the point of view of the actor.

Public function Virtual

FString

 

GetHumanReadableName()

Returns the human readable string representation of an object.

Public function Virtual

void

 

K2_DestroyActor()

Destroy the actor

Public function Virtual

void

 

PostInitializeComponents()

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

Public function Virtual

void

 

Reset()

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

Public function Virtual

void

 

TickActor

(
    float DeltaTime,
    enum ELevelTick TickType,
    FActorTickFunction & ThisTickFuncti...
)

Controller Tick Controllers are never animated, and do not look for an owner to be ticked before them Non-player controllers don't support being an autonomous proxy

Overridden from UObject

Name Description

Public function Virtual

void

 

GetLifetimeReplicatedProps

(
    TArray < FLifetimeProperty >& OutLi...
)

Returns the properties used for network replication

Overridden from INavAgentInterface

Name Description

Public function Virtual

void

 

GetMoveGoalReachTest

(
    const AActor * MovingActor,
    const FVector & MoveOffset,
    FVector & GoalOffset,
    float& GoalRadius,
    float& GoalHalfHeight
)

Get cylinder for testing if actor has been reached

Public function Virtual

FVector

 

GetNavAgentLocation()

Retrieves Agent's location

Public function Virtual

const FNavAg ...

 

GetNavAgentPropertiesRef()

Retrieves FNavAgentProperties expressing navigation props and caps of represented agent the function will be renamed to GetNavAgentProperties in 4.8.

Public function Virtual

IPathFollowi ...

 

GetPathFollowingAgent()

Retrieves PathFollowingAgent for this NavAgent

Public function Virtual

bool

 

IsFollowingAPath()

Checks if the agent is actively following a navigation path

Public function Virtual

bool

 

ShouldPostponePathUpdates()

Allows delaying repath requests

See Also

References

Module

Engine

Header

Runtime/Engine/Classes/GameFramework/Controller.h