RealDocs

APawn::FaceRotation

function Engine Since 4.0
#include "GameFramework/Pawn.h"
Access: public Specifiers: virtual

Description

Updates the pawn's actor rotation to match the controller's ControlRotation, gated by the bUseControllerRotationPitch/Yaw/Roll flags. Called each tick by the movement system to keep the pawn body oriented correctly.

Caveats & Gotchas

  • This only applies components of the rotation where the corresponding bUseControllerRotation flag is true — if all three flags are false this function is a no-op. Forgetting to enable bUseControllerRotationYaw is the most common cause of a pawn that strafes without turning.
  • ACharacter overrides this to rotate the capsule independently from the mesh; if you call Super::FaceRotation() from a Character subclass you will rotate the capsule but animations and socket-based queries may lag one frame.

Signature

virtual void FaceRotation(FRotator NewControlRotation, float DeltaTime = 0.f)

Parameters

Name Type Description Default
NewControlRotation FRotator The controller's current ControlRotation passed in by the movement update.
DeltaTime float Time in seconds since the last frame, available for interpolation. 0.f

Return Type

void

Example

Override to smoothly interpolate yaw only C++
void AMyPawn::FaceRotation(FRotator NewControlRotation, float DeltaTime)
{
	FRotator CurrentRot = GetActorRotation();
	FRotator TargetRot = FRotator(0.f, NewControlRotation.Yaw, 0.f);
	FRotator SmoothedRot = FMath::RInterpTo(CurrentRot, TargetRot, DeltaTime, 10.f);
	SetActorRotation(SmoothedRot);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.