RealDocs

UCharacterMovementComponent::ComputeOrientToMovementRotation

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

Description

Computes the target rotation the character should turn toward based on its current Acceleration, used by PhysicsRotation() when bOrientRotationToMovement is true.

Caveats & Gotchas

  • Only called when bOrientRotationToMovement is true — if that flag is false (e.g. controller-driven rotation), this function is never reached, so overriding it alone won't change rotation behaviour.
  • Default implementation targets the direction of Acceleration, not Velocity, so a character sliding sideways with zero input acceleration will not reorient via this path.
  • Returns CurrentRotation unchanged (no turn) when Acceleration is near zero, since there's no meaningful direction to face.

Signature

virtual FRotator ComputeOrientToMovementRotation(const FRotator& CurrentRotation, float DeltaTime, FRotator& DeltaRotation) const;

Parameters

Name Type Description Default
CurrentRotation const FRotator& Current rotation of the Character.
DeltaTime float Time slice for this movement.
DeltaRotation FRotator& Proposed rotation change based on DeltaTime * RotationRate; may be modified by this function.

Return Type

FRotator

Example

Orienting toward velocity instead of acceleration C++
FRotator UMyCharacterMovementComponent::ComputeOrientToMovementRotation(const FRotator& CurrentRotation, float DeltaTime, FRotator& DeltaRotation) const
{
	if (Velocity.SizeSquared() < KINDA_SMALL_NUMBER)
	{
		return CurrentRotation;
	}
	return Velocity.ToOrientationRotator();
}

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.