RealDocs

UCharacterMovementComponent::PhysicsRotation

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

Description

Performs the character's rotation update for the given time slice, combining ShouldRemainVertical(), GetDeltaRotation(), and (if bOrientRotationToMovement is set) ComputeOrientToMovementRotation().

Caveats & Gotchas

  • Called every physics sub-step from most movement modes (walking, falling, swimming, flying), so it runs far more often than once per game tick under MaxSimulationIterations — expensive overrides compound quickly.
  • Does nothing if the character has no UpdatedComponent, or if rotation is fully locked (e.g. bUseControllerRotationPitch/Yaw/Roll combined with no rotation-affecting flags set).
  • This is the umbrella function most rotation customization should go through; overriding GetDeltaRotation() or ComputeOrientToMovementRotation() individually is usually safer than replacing PhysicsRotation() wholesale.

Signature

virtual void PhysicsRotation(float DeltaTime);

Parameters

Name Type Description Default
DeltaTime float Time slice to rotate over.

Return Type

void

Example

Adding a custom rotation clamp on top of default behaviour C++
void UMyCharacterMovementComponent::PhysicsRotation(float DeltaTime)
{
	Super::PhysicsRotation(DeltaTime);

	if (UpdatedComponent)
	{
		FRotator Rotation = UpdatedComponent->GetComponentRotation();
		Rotation.Pitch = FMath::ClampAngle(Rotation.Pitch, -45.f, 45.f);
		MoveUpdatedComponent(FVector::ZeroVector, Rotation, false);
	}
}

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.