Header <GameFramework/Character.h>

#include "GameFramework/Character.h"
Module: Engine Source: Engine/Source/Runtime/Engine/Classes/GameFramework/Character.h

Includes 13

<CoreMinimal.h>
<UObject/ObjectMacros.h>
<UObject/UObjectGlobals.h>
<Templates/SubclassOf.h>
<UObject/CoreNet.h>
<Engine/NetSerialization.h>
<Engine/EngineTypes.h>
<Components/ActorComponent.h>
<GameFramework/Actor.h>
<GameFramework/Pawn.h>
<GameFramework/CharacterMovementReplication.h>
<Animation/AnimationAsset.h>
<GameFramework/RootMotionSource.h>

Contents

ACharacter
Characters are Pawns that have a mesh, collision, and built-in movement logic. They are responsible for all physical interaction between the player or AI and the world, and also implement basic networking and input…
(uclass class : APawn)
Functions12 free functions
(namespace scope)

class ACharacter

class ACharacter : public APawnUCLASSconfig=GameBlueprintTypeMinimalAPI
Characters are Pawns that have a mesh, collision, and built-in movement logic. They are responsible for all physical interaction between the player or AI and the world, and also implement basic networking and input…

Constructors 1

ACharacter
ACharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
Default UObject constructor.

Member functions 118

GetLifetimeReplicatedProps
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
GetReplicatedCustomConditionState
virtual void GetReplicatedCustomConditionState(FCustomPropertyConditionState& OutActiveState) const override;
GetMesh
class USkeletalMeshComponent* GetMesh() const;
Returns Mesh subobject
GetCharacterMovement
template <class T> T* GetCharacterMovement() const;
UCharacterMovementComponent* GetCharacterMovement() const;
Returns CharacterMovement subobject
GetCapsuleComponent
class UCapsuleComponent* GetCapsuleComponent() const;
Returns CapsuleComponent subobject
SetBase
virtual void SetBase(UPrimitiveComponent* NewBase, const FName BoneName = NAME_None, bool bNotifyActor=true);
Sets the component the Character is walking on, used by CharacterMovement walking movement to be able to follow dynamic objects.
CacheInitialMeshOffset
virtual void CacheInitialMeshOffset(FVector MeshRelativeLocation, FRotator MeshRelativeRotation);UFUNCTIONBlueprintCallableCategory=Character
Cache mesh offset from capsule. This is used as the target for network smoothing interpolation, when the mesh is offset with lagged smoothing. This is automatically called during initialization; call this at runtime…
GetReplicatedBasedMovement_Mutable
FBasedMovementInfo& GetReplicatedBasedMovement_Mutable();protected
This is the Replicated version of relative movement. Do not modify on simulated proxies! Returns non-const ReplicatedBasedMovement.
SetReplicatedBasedMovement
void SetReplicatedBasedMovement(const FBasedMovementInfo& InReplicatedBasedMovement);protected
This is the Replicated version of relative movement. Do not modify on simulated proxies! Sets ReplicatedBasedMovement
OnRep_ReplicatedBasedMovement
virtual void OnRep_ReplicatedBasedMovement();UFUNCTION
Rep notify for ReplicatedBasedMovement
SetReplicateMovement
virtual void SetReplicateMovement(bool bInReplicateMovement) override;
Set whether this actor's movement replicates to network clients.
ShouldReplicateAcceleration
virtual bool ShouldReplicateAcceleration() const;protected
Whether this Character should include acceleration data in its replicated movement
BaseChange
virtual void BaseChange();protected
Event called after actor's base changes (if SetBase was requested to notify us with bNotifyPawn).
SetReplicatedServerLastTransformUpdateTimeStamp
void SetReplicatedServerLastTransformUpdateTimeStamp(const float InReplicatedServerLastTransformUpdateTimeStamp);protected
This is the value of the CharacterMovement timestamp, and is replicated down to SimulatedProxies to assist with visual smoothing of the character. May not be updated every frame to reduce bandwidth. This function…
SetReplayLastTransformUpdateTimeStamp
void SetReplayLastTransformUpdateTimeStamp(const float InReplayLastTransformUpdateTimeStamp);protected
This is updated every frame to the latest timestamp, but only replicated to Replays, this is because we want to save positions to the replay replication connection each frame to ensure smooth movement. Sets…
SetReplicatedGravityDirection
void SetReplicatedGravityDirection(const FVector& InReplicatedGravityDirection);protected
CharacterMovement Custom gravity direction replicated for simulated proxies. This function sets ReplicatedGravityDirection and also marks property as dirty.
OnRep_ReplayLastTransformUpdateTimeStamp
void OnRep_ReplayLastTransformUpdateTimeStamp();UFUNCTION
GetReplicatedServerLastTransformUpdateTimeStamp
float GetReplicatedServerLastTransformUpdateTimeStamp() const;
This is the value of the CharacterMovement timestamp, and is replicated down to SimulatedProxies to assist with visual smoothing of the character. May not be updated every frame to reduce bandwidth. This is the…
GetReplayLastTransformUpdateTimeStamp
float GetReplayLastTransformUpdateTimeStamp() const;
This is updated every frame to the latest timestamp, but only replicated to Replays, this is because we want to save positions to the replay replication connection each frame to ensure smooth movement. This is the…
GetBasedMovement
const FBasedMovementInfo& GetBasedMovement() const;
Accessor for BasedMovement
GetReplicatedBasedMovement
const FBasedMovementInfo& GetReplicatedBasedMovement() const;
Accessor for ReplicatedBasedMovement
SaveRelativeBasedMovement
void SaveRelativeBasedMovement(const FVector& NewRelativeLocation, const FRotator& NewRotation, bool bRelativeRotation);
Save a new relative location in BasedMovement and a new rotation with is either relative or absolute.
GetReplicatedMovementMode
uint8 GetReplicatedMovementMode() const;
CharacterMovement MovementMode (and custom mode) replicated for simulated proxies. Use CharacterMovementComponent::UnpackNetworkMovementMode() to translate it. Returns ReplicatedMovementMode
GetBaseTranslationOffset
FVector GetBaseTranslationOffset() const;UFUNCTIONBlueprintCallableCategory=Character
Get the saved translation offset of mesh. This is how much extra offset is applied from the center of the capsule.
GetBaseRotationOffset
virtual FQuat GetBaseRotationOffset() const;
Get the saved rotation offset of mesh. This is how much extra rotation is applied from the capsule rotation.
GetBaseRotationOffsetRotator
FRotator GetBaseRotationOffsetRotator() const;UFUNCTIONBlueprintCallableCategory=Character
Get the saved rotation offset of mesh. This is how much extra rotation is applied from the capsule rotation.
GetGravityDirection
virtual FVector GetGravityDirection() const override;
Returns vector direction of gravity
GetGravityTransform
virtual FQuat GetGravityTransform() const override;
Returns a quaternion transforming from world space into gravity relative space
GetReplicatedGravityDirection
virtual FVector GetReplicatedGravityDirection() const;
Returns replicated gravity direction for simulated proxies
OnRep_IsCrouched
virtual void OnRep_IsCrouched();UFUNCTION
Handle Crouching replicated from server
SetReplicatedMovementMode
void SetReplicatedMovementMode(const uint8 InReplicatedMovementMode);protected
Sets CharacterMovement MovementMode (and custom mode) replicated for simulated proxies. Use CharacterMovementComponent::UnpackNetworkMovementMode() to translate it. This function sets the compressed value of…
PostLoad
virtual void PostLoad() override;
BeginPlay
virtual void BeginPlay() override;
ClearCrossLevelReferences
virtual void ClearCrossLevelReferences() override;
PreNetReceive
virtual void PreNetReceive() override;
PostNetReceive
virtual void PostNetReceive() override;
GatherCurrentMovement
virtual void GatherCurrentMovement() override;
OnRep_ReplicatedMovement
virtual void OnRep_ReplicatedMovement() override;
PostNetReceiveLocationAndRotation
virtual void PostNetReceiveLocationAndRotation() override;
GetSimpleCollisionCylinder
virtual void GetSimpleCollisionCylinder(float& CollisionRadius, float& CollisionHalfHeight) const override;
FindComponentByClass
virtual UActorComponent* FindComponentByClass(const TSubclassOf<UActorComponent> ComponentClass) const override;
template<class T> T* FindComponentByClass() const;
TornOff
virtual void TornOff() override;
NotifyActorBeginOverlap
virtual void NotifyActorBeginOverlap(AActor* OtherActor);
NotifyActorEndOverlap
virtual void NotifyActorEndOverlap(AActor* OtherActor);
GetNavAgentLocation
virtual FVector GetNavAgentLocation() const override;
PostInitializeComponents
virtual void PostInitializeComponents() override;
GetMovementComponent
virtual UPawnMovementComponent* GetMovementComponent() const override;
GetMovementBase
virtual UPrimitiveComponent* GetMovementBase() const override final;
GetDefaultHalfHeight
virtual float GetDefaultHalfHeight() const override;
TurnOff
virtual void TurnOff() override;
Restart
virtual void Restart() override;
PawnClientRestart
virtual void PawnClientRestart() override;
PossessedBy
virtual void PossessedBy(AController* NewController) override;
UnPossessed
virtual void UnPossessed() override;
SetupPlayerInputComponent
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
DisplayDebug
virtual void DisplayDebug(class UCanvas* Canvas, const FDebugDisplayInfo& DebugDisplay, float& YL, float& YPos) override;
RecalculateBaseEyeHeight
virtual void RecalculateBaseEyeHeight() override;
UpdateNavigationRelevance
virtual void UpdateNavigationRelevance() override;
ApplyDamageMomentum
virtual void ApplyDamageMomentum(float DamageTaken, FDamageEvent const& DamageEvent, APawn* PawnInstigator, AActor* DamageCauser);
Apply momentum caused by damage.
Jump
virtual void Jump();UFUNCTIONBlueprintCallableCategory=Character
Make the character jump on the next update. If you want your character to jump according to the time that the jump key is held, then you can set JumpMaxHoldTime to some non-zero value. Make sure in this case to call…
StopJumping
virtual void StopJumping();UFUNCTIONBlueprintCallableCategory=Character
Stop the character from jumping on the next update. Call this from an input event (such as a button 'up' event) to cease applying jump Z-velocity. If this is not called, then jump z-velocity will be applied until…
CanJump
bool CanJump() const;UFUNCTIONBlueprintCallableCategory=Character
Check if the character can jump in the current state.
GetProxyIsJumpForceApplied
bool GetProxyIsJumpForceApplied() const;
Indicates that this Character is currently under the force of a jump (if JumpMaxHoldTime is non-zero). IsJumpProvidingForce() handles this as well. This function returns bProxyIsJumpForceApplied
SetProxyIsJumpForceApplied
void SetProxyIsJumpForceApplied(const bool bInProxyIsJumpForceApplied);
Set to indicate that this Character is currently under the force of a jump (if JumpMaxHoldTime is non-zero). IsJumpProvidingForce() handles this as well. This function sets bProxyIsJumpForceApplied
IsCrouched
bool IsCrouched() const;
Set by character movement to specify that this Character is currently crouched. This function returns bIsCrouched.
SetIsCrouched
void SetIsCrouched(const bool bInIsCrouched);
Specifies whether this Character is currently crouched or not. This function sets bIsCrouched and marks property as dirty.
CanJumpInternal
bool CanJumpInternal() const;protectedUFUNCTIONBlueprintNativeEventCategory=Character
Customizable event to check if the character can jump in the current state. Default implementation returns true if the character is on the ground and not crouching, has a valid CharacterMovementComponent and…
JumpIsAllowedInternal
bool JumpIsAllowedInternal() const;protected
ResetJumpState
virtual void ResetJumpState();
Marks character as not trying to jump
IsJumpProvidingForce
virtual bool IsJumpProvidingForce() const;UFUNCTIONBlueprintCallableCategory=Character
True if jump is actively providing a force, such as when the jump key is held and the time it has been held is less than JumpMaxHoldTime.
PlayAnimMontage
virtual float PlayAnimMontage(class UAnimMontage* AnimMontage, float InPlayRate = 1.f, FName StartSectionName = NAME_None);UFUNCTIONBlueprintCallableCategory=Animation
Play Animation Montage on the character mesh. Returns the length of the animation montage in seconds, or 0.f if failed to play.
StopAnimMontage
virtual void StopAnimMontage(class UAnimMontage* AnimMontage = nullptr);UFUNCTIONBlueprintCallableCategory=Animation
Stop Animation Montage. If nullptr, it will stop what's currently active. The Blend Out Time is taken from the montage asset that is being stopped.
GetCurrentMontage
class UAnimMontage* GetCurrentMontage() const;UFUNCTIONBlueprintCallableCategory=Animation
Return current playing Montage
LaunchCharacter
virtual void LaunchCharacter(FVector LaunchVelocity, bool bXYOverride, bool bZOverride);UFUNCTIONBlueprintCallableCategory=Character
Set a pending launch velocity on the Character. This velocity will be processed on the next CharacterMovementComponent tick, and will set it to the "falling" state. Triggers the OnLaunched event.
OnLaunched
void OnLaunched(FVector LaunchVelocity, bool bXYOverride, bool bZOverride);UFUNCTIONBlueprintImplementableEvent
Let blueprint know that we were launched
OnJumped
void OnJumped();UFUNCTIONBlueprintNativeEventCategory=Character
Event fired when the character has just started jumping
Falling
virtual void Falling();
Called when the character's movement enters falling
NotifyJumpApex
virtual void NotifyJumpApex();
Called when character's jump reaches Apex. Needs CharacterMovement->bNotifyApex = true
Landed
virtual void Landed(const FHitResult& Hit);
Called upon landing when falling, to perform actions based on the Hit result. Triggers the OnLanded event. Note that movement mode is still "Falling" during this event. Current Velocity value is the velocity at the…
OnLanded
void OnLanded(const FHitResult& Hit);UFUNCTIONBlueprintImplementableEvent
Called upon landing when falling, to perform actions based on the Hit result. Note that movement mode is still "Falling" during this event. Current Velocity value is the velocity at the time of landing. Consider…
OnWalkingOffLedge
void OnWalkingOffLedge(const FVector& PreviousFloorImpactNormal, const FVector& PreviousFloorContactNormal, const FVector& PreviousLocation, float TimeDelta);UFUNCTIONBlueprintNativeEventCategory=Character
Event fired when the Character is walking off a surface and is about to fall because CharacterMovement->CurrentFloor became unwalkable. If CharacterMovement->MovementMode does not change during this event then the…
MoveBlockedBy
virtual void MoveBlockedBy(const FHitResult& Impact);
Called when pawn's movement is blocked
Crouch
virtual void Crouch(bool bClientSimulation = false);UFUNCTIONBlueprintCallableCategory=Character
Request the character to start crouching. The request is processed on the next update of the CharacterMovementComponent.
UnCrouch
virtual void UnCrouch(bool bClientSimulation = false);UFUNCTIONBlueprintCallableCategory=Character
Request the character to stop crouching. The request is processed on the next update of the CharacterMovementComponent.
CanCrouch
virtual bool CanCrouch() const;UFUNCTIONBlueprintCallableCategory=Character
OnEndCrouch
virtual void OnEndCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust);
Called when Character stops crouching. Called on non-owned Characters through bIsCrouched replication.
K2_OnEndCrouch
void K2_OnEndCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust);UFUNCTIONBlueprintImplementableEvent
Event when Character stops crouching.
OnStartCrouch
virtual void OnStartCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust);
Called when Character crouches. Called on non-owned Characters through bIsCrouched replication.
K2_OnStartCrouch
void K2_OnStartCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust);UFUNCTIONBlueprintImplementableEvent
Event when Character crouches.
RecalculateCrouchedEyeHeight
void RecalculateCrouchedEyeHeight();
Calculates the crouched eye height based on movement component settings
OnMovementModeChanged
virtual void OnMovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode = 0);
Called from CharacterMovementComponent to notify the character that the movement mode has changed.
K2_OnMovementModeChanged
void K2_OnMovementModeChanged(EMovementMode PrevMovementMode, EMovementMode NewMovementMode, uint8 PrevCustomMode, uint8 NewCustomMode);UFUNCTIONBlueprintImplementableEvent
Called from CharacterMovementComponent to notify the character that the movement mode has changed.
K2_UpdateCustomMovement
void K2_UpdateCustomMovement(float DeltaTime);UFUNCTIONBlueprintImplementableEvent
Event for implementing custom character movement mode. Called by CharacterMovement if MovementMode is set to Custom.
ShouldNotifyLanded
virtual bool ShouldNotifyLanded(const struct FHitResult& Hit);
Returns true if the Landed() event should be called. Used by CharacterMovement to prevent notifications while playing back network moves.
CheckJumpInput
virtual void CheckJumpInput(float DeltaTime);
Trigger jump if jump button has been pressed.
ClearJumpInput
virtual void ClearJumpInput(float DeltaTime);
Update jump input state after having checked input.
GetJumpMaxHoldTime
virtual float GetJumpMaxHoldTime() const;
Get the maximum jump time for the character. Note that if StopJumping() is not called before the max jump hold time is reached, then the character will carry on receiving vertical velocity. Therefore it is usually…
RootMotionDebugClientPrintOnScreen
void RootMotionDebugClientPrintOnScreen(const FString& InString);UFUNCTIONReliableClient
FindRootMotionRepMove
int32 FindRootMotionRepMove(const FAnimMontageInstance& ClientMontageInstance) const;
Find usable root motion replicated move from our buffer. Goes through the buffer back in time, to find the first move that clears 'CanUseRootMotionRepMove' below. Returns index of that move or INDEX_NONE otherwise.
CanUseRootMotionRepMove
bool CanUseRootMotionRepMove(const FSimulatedRootMotionReplicatedMove& RootMotionRepMove, const FAnimMontageInstance& ClientMontageInstance) const;
True if buffered move is usable to teleport client back to.
RestoreReplicatedMove
bool RestoreReplicatedMove(const FSimulatedRootMotionReplicatedMove& RootMotionRepMove);
Restore actor to an old buffered move.
OnUpdateSimulatedPosition
virtual void OnUpdateSimulatedPosition(const FVector& OldLocation, const FQuat& OldRotation);
Called on client after position update is received to respond to the new location and rotation. Actual change in location is expected to occur in CharacterMovement->SmoothCorrection(), after which this occurs.…
GetRepRootMotion
const FRepRootMotionMontage& GetRepRootMotion() const;
Replicated Root Motion montage. Returns RepRootMotion
GetRepRootMotion_Mutable
FRepRootMotionMontage& GetRepRootMotion_Mutable();
Replicated Root Motion montage. Returns non-const RepRootMotion
SetRepRootMotion
void SetRepRootMotion(const FRepRootMotionMontage& InRepRootMotion);
Replicated Root Motion montage. Sets RepRootMotion
OnRep_RootMotion
void OnRep_RootMotion();UFUNCTION
Handles replicated root motion properties on simulated proxies and position correction.
SimulatedRootMotionPositionFixup
void SimulatedRootMotionPositionFixup(float DeltaSeconds);
Position fix up for Simulated Proxies playing Root Motion
GetRootMotionAnimMontageInstance
FAnimMontageInstance * GetRootMotionAnimMontageInstance() const;
Get FAnimMontageInstance playing RootMotion
IsPlayingRootMotion
bool IsPlayingRootMotion() const;UFUNCTIONBlueprintCallableCategory=Animation
True if we are playing Anim root motion right now
HasAnyRootMotion
bool HasAnyRootMotion() const;UFUNCTIONBlueprintCallableCategory=Animation
True if we are playing root motion from any source right now (anim root motion, root motion source)
IsPlayingNetworkedRootMotionMontage
bool IsPlayingNetworkedRootMotionMontage() const;UFUNCTIONBlueprintCallableCategory=Animation
True if we are playing Root Motion right now, through a Montage with RootMotionMode == ERootMotionMode::RootMotionFromMontagesOnly. This means code path for networked root motion is enabled.
SetAnimRootMotionTranslationScale
void SetAnimRootMotionTranslationScale(float InAnimRootMotionTranslationScale = 1.f);
Sets scale to apply to root motion translation on this Character
GetAnimRootMotionTranslationScale
float GetAnimRootMotionTranslationScale() const;UFUNCTIONBlueprintCallableCategory=Animation
Scale to apply to root motion translation on this Character. Returns current value of AnimRootMotionScale.
PreReplication
virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override;
Called on the actor right before replication occurs. Only called on Server, and for autonomous proxies if recording a Client Replay.
PreReplicationForReplay
virtual void PreReplicationForReplay(IRepChangedPropertyTracker& ChangedPropertyTracker) override;
Called on the actor right before replication occurs. Called for everyone when recording a Client Replay, including Simulated Proxies.
FillAsyncInput
void FillAsyncInput(FCharacterAsyncInput& Input) const;
Async simulation API
InitializeAsyncOutput
void InitializeAsyncOutput(FCharacterAsyncOutput& Output) const;
ApplyAsyncOutput
void ApplyAsyncOutput(const FCharacterAsyncOutput& Output);

Functions

Free functions 12

IsDynamicBase
bool IsDynamicBase(const UPrimitiveComponent* MovementBase);
Determine whether MovementBase can possibly move.
IsSimulatedBase
bool IsSimulatedBase(const UPrimitiveComponent* MovementBase);
Determine whether MovementBase is simulating or attached to a simulating object.
UseRelativeLocation
bool UseRelativeLocation(const UPrimitiveComponent* MovementBase);
Determine if we should use relative positioning when based on a component (because it may move).
AddTickDependency
void AddTickDependency(FTickFunction& BasedObjectTick, UPrimitiveComponent* NewBase);
Ensure that BasedObjectTick ticks after NewBase
RemoveTickDependency
void RemoveTickDependency(FTickFunction& BasedObjectTick, UPrimitiveComponent* OldBase);
Remove tick dependency of BasedObjectTick on OldBase
GetMovementBaseVelocity
FVector GetMovementBaseVelocity(const UPrimitiveComponent* MovementBase, const FName BoneName);
Get the velocity of the given component, first checking the ComponentVelocity and falling back to the physics velocity if necessary.
GetMovementBaseTangentialVelocity
FVector GetMovementBaseTangentialVelocity(const UPrimitiveComponent* MovementBase, const FName BoneName, const FVector& WorldLocation);
Get the tangential velocity at WorldLocation for the given component.
GetMovementBaseTransform
bool GetMovementBaseTransform(const UPrimitiveComponent* MovementBase, const FName BoneName, FVector& OutLocation, FQuat& OutQuat);
Get the transform (local-to-world) for the given MovementBase, optionally at the location of a bone. Returns false if MovementBase is nullptr, or if BoneName is not a valid bone.
TransformLocationToWorld
bool TransformLocationToWorld(const UPrimitiveComponent* MovementBase, const FName BoneName, const FVector& LocalLocation, FVector& OutLocationWorldSpace);
Convert a local location to a world location for a given MovementBase. Returns false if MovementBase is nullptr, or if BoneName is not a valid bone. Scaling is ignored.
TransformLocationToLocal
bool TransformLocationToLocal(const UPrimitiveComponent* MovementBase, const FName BoneName, const FVector& WorldSpaceLocation, FVector& OutLocalLocation);
Convert a world location to a local location for a given MovementBase, optionally at the location of a bone. Returns false if MovementBase is nullptr, or if BoneName is not a valid bone. Scaling is ignored.
TransformDirectionToWorld
bool TransformDirectionToWorld(const UPrimitiveComponent* MovementBase, const FName BoneName, const FVector& LocalDirection, FVector& OutDirectionWorldSpace);
Convert a local direction to a world direction for a given MovementBase. Returns false if MovementBase is nullptr, or if BoneName is not a valid bone. Scaling is ignored.
TransformDirectionToLocal
bool TransformDirectionToLocal(const UPrimitiveComponent* MovementBase, const FName BoneName, const FVector& WorldSpaceDirection, FVector& OutLocalDirection);
Convert a world direction to a local direction for a given MovementBase, optionally relative to the orientation of a bone. Returns false if MovementBase is nullptr, or if BoneName is not a valid bone. Scaling is ignored.