Navigation
API > API/Runtime > API/Runtime/Engine
Pawn is the base class of all actors that can be possessed by players or AI. They are the physical representations of players and creatures in a level.
| Name | APawn |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Classes/GameFramework/Pawn.h |
| Include Path | #include "GameFramework/Pawn.h" |
Syntax
UCLASS (Config=Game, BlueprintType, Blueprintable, HideCategories=(Navigation),
Meta=(ShortTooltip="A Pawn is an actor that can be 'possessed' and receive input from a controller."),
MinimalAPI)
class APawn :
public AActor ,
public INavAgentInterface
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → AActor → APawn
Implements Interfaces
Derived Classes
APawn derived class hierarchy
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
APawn
(
const FObjectInitializer& ObjectInitializer |
Default UObject constructor. | GameFramework/Pawn.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| OnPawnBeginPlay | FOnPawnBeginPlay | A delegate that broadcasts a notification whenever BeginPlay() is called | GameFramework/Pawn.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| AIControllerClass | TSubclassOf< AController > | Default class to use when pawn is controlled by AI. | GameFramework/Pawn.h |
|
| AllowedYawError | float | Max difference between pawn's Rotation.Yaw and GetDesiredRotation().Yaw for pawn to be considered as having reached its desired rotation | GameFramework/Pawn.h | |
| AutoPossessAI | EAutoPossessAI | Determines when the Pawn creates and is possessed by an AI Controller (on level start, when spawned, etc). | GameFramework/Pawn.h |
|
| AutoPossessPlayer | TEnumAsByte< EAutoReceiveInput::Type > | Determines which PlayerController, if any, should automatically possess the pawn when the level starts or when the pawn is spawned. | GameFramework/Pawn.h |
|
| BaseEyeHeight | float | Base eye height above collision center. | GameFramework/Pawn.h |
|
| bCanAffectNavigationGeneration | uint32 | If set to false (default) given pawn instance will never affect navigation generation (but components could). | GameFramework/Pawn.h |
|
| bUseControllerRotationPitch | uint32 | If true, this Pawn's pitch will be updated to match the Controller's ControlRotation pitch, if controlled by a PlayerController. | GameFramework/Pawn.h |
|
| bUseControllerRotationRoll | uint32 | If true, this Pawn's roll will be updated to match the Controller's ControlRotation roll, if controlled by a PlayerController. | GameFramework/Pawn.h |
|
| bUseControllerRotationYaw | uint32 | If true, this Pawn's yaw will be updated to match the Controller's ControlRotation yaw, if controlled by a PlayerController. | GameFramework/Pawn.h |
|
| Controller | TObjectPtr< AController > | Controller currently possessing this Actor | GameFramework/Pawn.h |
|
| LastHitBy | TObjectPtr< AController > | Controller of the last Actor that caused us damage. | GameFramework/Pawn.h |
|
| PreviousController | TObjectPtr< AController > | Previous controller that was controlling this pawn since the last controller change notification | GameFramework/Pawn.h |
|
| ReceiveControllerChangedDelegate | FPawnControllerChangedSignature | Event called after a pawn's controller has changed, on the server and owning client. | GameFramework/Pawn.h |
|
| ReceiveRestartedDelegate | FPawnRestartedSignature | Event called after a pawn has been restarted, usually by a possession change. | GameFramework/Pawn.h |
|
| RemoteViewPitch | uint8 | DEPRECTED, use RemoteViewPitch16 instead. | GameFramework/Pawn.h |
|
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bInputEnabled | uint32 | Whether this Pawn's input handling is enabled. | GameFramework/Pawn.h | |
| bProcessingOutsideWorldBounds | uint32 | Used to prevent re-entry of OutsideWorldBounds event. | GameFramework/Pawn.h | |
| PlayerState | TObjectPtr< APlayerState > | If Pawn is possessed by a player, points to its Player State. | GameFramework/Pawn.h |
|
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void AddControllerPitchInput
(
float Val |
Add input (affecting Pitch) to the Controller's ControlRotation, if it is a local PlayerController. | GameFramework/Pawn.h |
|
virtual void AddControllerRollInput
(
float Val |
Add input (affecting Roll) to the Controller's ControlRotation, if it is a local PlayerController. | GameFramework/Pawn.h |
|
virtual void AddControllerYawInput
(
float Val |
Add input (affecting Yaw) to the Controller's ControlRotation, if it is a local PlayerController. | GameFramework/Pawn.h |
|
virtual void AddMovementInput
(
FVector WorldDirection, |
Add movement input along the given world direction vector (usually normalized) scaled by 'ScaleValue'. | GameFramework/Pawn.h |
|
virtual FVector ConsumeMovementInputVector () |
Returns the pending input vector and resets it to zero. | GameFramework/Pawn.h |
|
virtual void DetachFromControllerPendingDestroy() |
Call this function to detach safely pawn from its controller, knowing that we will be destroyed soon. | GameFramework/Pawn.h |
|
void DispatchRestart
(
bool bCallClientRestart |
Wrapper function to call correct restart functions, enable bCallClientRestart if this is a locally owned player pawn or equivalent | GameFramework/Pawn.h | |
virtual void DisplayDebug
(
UCanvas* Canvas, |
GameFramework/Pawn.h | ||
virtual void FaceRotation
(
FRotator NewControlRotation, |
Updates Pawn's rotation to the given rotation, assumed to be the Controller's ControlRotation. | GameFramework/Pawn.h | |
virtual FRotator GetBaseAimRotation () |
Return the aim rotation for the Pawn. | GameFramework/Pawn.h |
|
AController * GetController () |
Returns controller for this actor. | GameFramework/Pawn.h |
|
T * GetController () |
Returns controller for this actor cast to the template type. May return NULL is the cast fails. | GameFramework/Pawn.h | |
FRotator GetControlRotation() |
Get the rotation of the Controller, often the 'view' rotation of this Pawn. | GameFramework/Pawn.h |
|
virtual float GetDefaultHalfHeight () |
Returns The half-height of the default Pawn, scaled by the component scale. | GameFramework/Pawn.h | |
virtual FVector GetGravityDirection() |
Returns vector direction of gravity | GameFramework/Pawn.h | |
virtual FQuat GetGravityTransform() |
Returns a quaternion transforming from world space into gravity relative space | GameFramework/Pawn.h | |
FVector GetLastMovementInputVector () |
Return the last input vector in world space that was processed by ConsumeMovementInputVector(), which is usually done by the Pawn or PawnMovementComponent. | GameFramework/Pawn.h |
|
APlayerController * GetLocalViewingPlayerController() |
Returns local Player Controller viewing this pawn, whether it is controlling or spectating | GameFramework/Pawn.h |
|
virtual UPrimitiveComponent * GetMovementBase() |
Return PrimitiveComponent we are based on (standing on, attached to, and moving on). | GameFramework/Pawn.h | |
virtual UPawnMovementComponent * GetMovementComponent () |
Return our PawnMovementComponent, if we have one. | GameFramework/Pawn.h |
|
TSubclassOf< UInputComponent > GetOverrideInputComponentClass() |
GameFramework/Pawn.h |
|
|
virtual UPawnNoiseEmitterComponent * GetPawnNoiseEmitterComponent () |
Return our PawnNoiseEmitterComponent, if any. | GameFramework/Pawn.h | |
virtual APhysicsVolume * GetPawnPhysicsVolume() |
Return Physics Volume for this Pawn | GameFramework/Pawn.h | |
virtual FVector GetPawnViewLocation() |
Returns Pawn's eye location | GameFramework/Pawn.h | |
FVector GetPendingMovementInputVector () |
Return the pending input vector in world space. | GameFramework/Pawn.h |
|
| Returns the Platform User ID of the PlayerController that is controlling this character. | GameFramework/Pawn.h |
|
|
| If Pawn is possessed by a player, returns its Player State. | GameFramework/Pawn.h | ||
T * GetPlayerState () |
Templated convenience version of GetPlayerState. | GameFramework/Pawn.h | |
T * GetPlayerStateChecked() |
Templated convenience version of GetPlayerState which checks the type is as presumed. | GameFramework/Pawn.h | |
uint16 GetRemoteViewPitch() |
Replicated pitch value so we can see where remote clients are looking. | GameFramework/Pawn.h | |
virtual FRotator GetViewRotation() |
Get the view rotation of the Pawn (direction they are looking, normally Controller->ControlRotation). | GameFramework/Pawn.h | |
virtual bool InFreeCam() |
Returns true if player is viewing this Pawn in FreeCam | GameFramework/Pawn.h | |
bool InputEnabled () |
Whether this Pawn's input handling is enabled. | GameFramework/Pawn.h | |
void Internal_AddMovementInput
(
FVector WorldAccel, |
Internal function meant for use only within Pawn or by a PawnMovementComponent. | GameFramework/Pawn.h | |
FVector Internal_ConsumeMovementInputVector () |
Internal function meant for use only within Pawn or by a PawnMovementComponent. | GameFramework/Pawn.h | |
FVector Internal_GetLastMovementInputVector () |
Internal function meant for use only within Pawn or by a PawnMovementComponent. | GameFramework/Pawn.h | |
FVector Internal_GetPendingMovementInputVector () |
Internal function meant for use only within Pawn or by a PawnMovementComponent. | GameFramework/Pawn.h | |
virtual bool IsBotControlled() |
Returns true if controlled by a bot. | GameFramework/Pawn.h |
|
bool IsControlled() |
See if this actor is currently being controlled | GameFramework/Pawn.h |
|
virtual bool IsLocallyControlled() |
Returns true if controlled by a local (not network) Controller. | GameFramework/Pawn.h |
|
bool IsLocallyViewed () |
Is this pawn the ViewTarget of a local PlayerController? Helpful for determining whether the pawn is visible/critical for any VFX. | GameFramework/Pawn.h |
|
bool IsLocalPlayerControllerViewingAPawn() |
GameFramework/Pawn.h | ||
virtual bool IsMoveInputIgnored () |
Helper to see if move input is ignored. | GameFramework/Pawn.h |
|
virtual bool IsPawnControlled() |
Check if this actor is currently being controlled at all (the actor has a valid Controller, which will be false for remote clients) | GameFramework/Pawn.h |
|
virtual bool IsPlayerControlled () |
Returns true if controlled by a human player (possessed by a PlayerController). | GameFramework/Pawn.h |
|
void MoveIgnoreActorAdd
(
AActor* ActorToIgnore |
Add an Actor to ignore by Pawn's movement collision | GameFramework/Pawn.h | |
void MoveIgnoreActorRemove
(
AActor* ActorToIgnore |
Remove an Actor to ignore by Pawn's movement collision | GameFramework/Pawn.h | |
virtual void NotifyControllerChanged () |
Call to notify about a change in controller, on both the server and owning client. | GameFramework/Pawn.h | |
virtual void NotifyRestarted () |
Notifies other systems that a pawn has been restarted. | GameFramework/Pawn.h | |
virtual void OnRep_Controller() |
Called when Controller is replicated | GameFramework/Pawn.h | |
virtual void OnRep_PlayerState() |
PlayerState Replication Notification Callback | GameFramework/Pawn.h | |
virtual void PawnClientRestart() |
Called on the owning client of a player-controlled Pawn when it is restarted, this calls Restart() | GameFramework/Pawn.h | |
void PawnMakeNoise
(
float Loudness, |
Inform AIControllers that you've made a noise they might hear (they are sent a HearNoise message if they have bHearNoises==true) The instigator of this sound is the pawn which is used to call MakeNoise. | GameFramework/Pawn.h |
|
virtual void PawnStartFire
(
uint8 FireModeNum |
Handle StartFire() passed from PlayerController | GameFramework/Pawn.h | |
virtual void PossessedBy
(
AController* NewController |
Called when this Pawn is possessed. Only called on the server (or in standalone). | GameFramework/Pawn.h | |
virtual bool ReachedDesiredRotation() |
Return true if yaw is within AllowedYawError of desired yaw | GameFramework/Pawn.h | |
virtual void RecalculateBaseEyeHeight() |
Set BaseEyeHeight based on current state. | GameFramework/Pawn.h | |
void ReceiveControllerChanged
(
AController* OldController, |
Event called after a pawn's controller has changed, on the server and owning client. | GameFramework/Pawn.h |
|
void ReceivePossessed
(
AController* NewController |
Event called when the Pawn is possessed by a Controller. | GameFramework/Pawn.h |
|
void ReceiveRestarted () |
Event called after a pawn has been restarted, usually by a possession change. | GameFramework/Pawn.h |
|
void ReceiveUnpossessed
(
AController* OldController |
Event called when the Pawn is no longer possessed by a Controller. | GameFramework/Pawn.h |
|
virtual void Restart () |
Called when the Pawn is being restarted (usually by being possessed by a Controller). | GameFramework/Pawn.h | |
void SetCanAffectNavigationGeneration
(
bool bNewValue, |
Use SetCanAffectNavigationGeneration to change this value at runtime. | GameFramework/Pawn.h |
|
void SetController
(
AController* InController |
Sets controller for this actor | GameFramework/Pawn.h | |
virtual void SetPlayerDefaults() |
Make sure pawn properties are back to default. | GameFramework/Pawn.h | |
void SetPlayerState
(
APlayerState* NewPlayerState |
Set the Pawn's Player State. | GameFramework/Pawn.h | |
void SetRemoteViewPitch
(
double NewRemoteViewPitch |
Set Pawn ViewPitch, so we can see where remote clients are looking. Maps 360.0 degrees into 16 bits | GameFramework/Pawn.h | |
virtual bool ShouldTakeDamage
(
float Damage, |
Return true if we are in a state to take damage (checked at the start of TakeDamage. Subclasses may check this as well if they override TakeDamage and don't want to potentially trigger TakeDamage actions by checking if it returns zero in the super class. | GameFramework/Pawn.h | |
virtual void SpawnDefaultController() |
Spawn default controller for this Pawn, and get possessed by it. | GameFramework/Pawn.h |
|
virtual void TurnOff() |
Freeze pawn - stop sounds, animations, physics, weapon firing | GameFramework/Pawn.h | |
virtual void UnPossessed() |
Called when our Controller no longer possesses us. Only called on the server (or in standalone). | GameFramework/Pawn.h | |
void UpdateNavAgent() |
Updates MovementComponent's parameters used by navigation system | GameFramework/Pawn.h | |
virtual void UpdateNavigationRelevance() |
Update all components relevant for navigation generators to match bCanAffectNavigationGeneration flag | GameFramework/Pawn.h |
Overridden from AActor
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void BecomeViewTarget
(
APlayerController* PC |
Called when this actor becomes the given PlayerController's ViewTarget. | GameFramework/Pawn.h | |
virtual void BeginPlay() |
Overridable native event for when play begins for this actor. | GameFramework/Pawn.h | |
virtual bool CanBeBaseForCharacter
(
APawn* APawn |
Overridden to defer to the RootComponent's CanCharacterStepUpOn setting if it is explicitly Yes or No. | GameFramework/Pawn.h | |
virtual void Destroyed() |
Called when this actor is explicitly being destroyed during gameplay or in the editor, not called during level streaming or gameplay ending | GameFramework/Pawn.h | |
virtual void DisableInput
(
APlayerController* PlayerController |
Removes this actor from the stack of input being handled by a PlayerController. | GameFramework/Pawn.h | |
virtual void EditorApplyRotation
(
const FRotator& DeltaRotation, |
Called by ApplyDeltaToActor to perform an actor class-specific operation based on widget manipulation. | GameFramework/Pawn.h | |
virtual void EnableInput
(
APlayerController* PlayerController |
Pushes this actor on to the stack of input being handled by a PlayerController. | GameFramework/Pawn.h | |
virtual void EndPlay
(
const EEndPlayReason::Type EndPlayReason |
Overridable function called whenever this actor is being removed from a level | GameFramework/Pawn.h | |
virtual void EndViewTarget
(
APlayerController* PC |
Called when this actor is no longer the given PlayerController's ViewTarget. | GameFramework/Pawn.h | |
virtual void GetActorEyesViewPoint
(
FVector& OutLocation, |
Returns the point of view of the actor. | GameFramework/Pawn.h | |
virtual FString GetHumanReadableName() |
Returns the human readable string representation of an object. | GameFramework/Pawn.h | |
virtual UNetConnection * GetNetConnection() |
Get the owning connection used for communicating between client/server | GameFramework/Pawn.h | |
virtual const AActor * GetNetOwner() |
Return the actor responsible for replication, if any. Typically the player controller | GameFramework/Pawn.h | |
virtual UPlayer * GetNetOwningPlayer () |
Return the owning UPlayer (if any) of this actor if it's role is ROLE_Authority. | GameFramework/Pawn.h | |
virtual UPlayer * GetNetOwningPlayerAnyRole () |
Return the owning UPlayer (if any) of this actor, regardless of it's current role. | GameFramework/Pawn.h | |
virtual APhysicsVolume * GetPhysicsVolume() |
Return Physics Volume for this Pawn | GameFramework/Pawn.h | |
virtual FVector GetVelocity() |
Returns velocity (in cm/s (Unreal Units/second) of the rootcomponent if it is either using physics or has an associated MovementComponent | GameFramework/Pawn.h | |
virtual bool IsBasedOnActor
(
const AActor* Other |
Iterates up the movement base chain to see whether or not this Actor is based on the given Actor, defaults to checking attachment | GameFramework/Pawn.h | |
| Checks to see if this actor is relevant for a specific network connection | GameFramework/Pawn.h | ||
virtual void OutsideWorldBounds() |
Called when the Actor is outside the hard limit on world bounds | GameFramework/Pawn.h | |
virtual void PostInitializeComponents() |
Allow actors to initialize themselves on the C++ side after all of their components have been initialized, only called during gameplay | GameFramework/Pawn.h | |
virtual void PostNetReceiveLocationAndRotation() |
Update location and rotation from ReplicatedMovement. Not called for simulated physics! | GameFramework/Pawn.h | |
virtual void PostNetReceiveVelocity
(
const FVector& NewVelocity |
Update velocity - typically from ReplicatedMovement, not called for simulated physics! | GameFramework/Pawn.h | |
virtual void PostRegisterAllComponents () |
Called after all the components in the Components array are registered, called both in editor and during gameplay. | GameFramework/Pawn.h | |
virtual void PreInitializeComponents() |
Called right before components are initialized, only called during gameplay | GameFramework/Pawn.h | |
virtual void PreReplication
(
IRepChangedPropertyTracker& ChangedPropertyTracker |
Called on the actor right before replication occurs. | GameFramework/Pawn.h | |
virtual void Reset() |
Reset actor to initial state - used when restarting level without reloading. | GameFramework/Pawn.h | |
virtual bool ShouldTickIfViewportsOnly () |
If true, actor is ticked even if TickType==LEVELTICK_ViewportsOnly | GameFramework/Pawn.h | |
virtual float TakeDamage
(
float DamageAmount, |
Apply damage to this actor. | GameFramework/Pawn.h | |
virtual void TeleportSucceeded
(
bool bIsATest |
Called from TeleportTo() when teleport succeeds | GameFramework/Pawn.h |
Overridden from UObject
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void GetLifetimeReplicatedProps
(
TArray< FLifetimeProperty >& OutLifetimeProps |
Returns the properties used for network replication, this needs to be overridden by all actor classes with native replicated properties | GameFramework/Pawn.h | |
virtual void PostEditChangeProperty
(
FPropertyChangedEvent& PropertyChangedEvent |
GameFramework/Pawn.h | ||
virtual void PostLoad() |
GameFramework/Pawn.h |
Overridden from INavAgentInterface
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void GetMoveGoalReachTest
(
const AActor* MovingActor, |
Get cylinder for testing if actor has been reached | GameFramework/Pawn.h |
|
virtual FVector GetNavAgentLocation() |
Basically retrieved pawn's location on navmesh | GameFramework/Pawn.h |
|
virtual const FNavAgentProperties & GetNavAgentPropertiesRef () |
Retrieves FNavAgentProperties expressing navigation props and caps of represented agent @NOTE the function will be renamed to GetNavAgentProperties in 4.8. | GameFramework/Pawn.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual UInputComponent * CreatePlayerInputComponent () |
Creates an InputComponent that can be used for custom input bindings. | GameFramework/Pawn.h | |
virtual void DestroyPlayerInputComponent() |
Destroys the player input component and removes any references to it. | GameFramework/Pawn.h | |
virtual AController * GetDamageInstigator
(
AController* InstigatedBy, |
Get the controller instigating the damage. | GameFramework/Pawn.h | |
virtual void OnPlayerStateChanged
(
APlayerState* NewPlayerState, |
Called on both the clientand server when ever SetPlayerState is called on this pawn. | GameFramework/Pawn.h | |
virtual void SetupPlayerInputComponent
(
UInputComponent* PlayerInputComponent |
Allows a Pawn to set up custom input bindings. | GameFramework/Pawn.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Gets the owning actor of the Movement Base Component on which the pawn is standing. | GameFramework/Pawn.h |
|