Skip to content

Character Rotation

Jared Taylor edited this page Aug 27, 2025 · 6 revisions

Image

Important

This will cover common rotation modes and common pitfalls

Warning

Do not directly set the character's rotation

Rotation Modes

There are 3 primary rotation modes

Strafe Direct/Snap

Tip

Shooter Games

If you set bUseControllerRotationYaw=true on your ACharacter, then you will get strafe rotation that snaps so that the character always directly faces the control rotation (camera)

This occurs in ACharacter::FaceRotation()

Strafe Smooth

Tip

Melee Games

If you set bUseControllerDesiredRotation=true on your UCharacterMovementComponent, then you will get strafe rotation that smoothly interpolates towards the control rotation (camera) based on RotationRate.Yaw.

This occurs in UCharacterMovementComponent::PhysicsRotation()

Orient to Movement

Tip

Adventure, Platformer, etc. Games

If you set bOrientRotationToMovement=true on your UCharacterMovementComponent, then you will get rotation that orients towards the Acceleration (input) direction when you move.

This occurs in UCharacterMovementComponent::PhysicsRotation()

Miscellaneous

Some games extend this further. Orient to Movement often adds an option bOrientToLastInputDirection so that you continue to rotate while stationary; you can take this implementation from my TurnInPlace repo.

BOTW/Mario 3D games restrain the acceleration into an arc creating circular movement.

And of course, plenty of games allow toggling between these modes such as BOTW switching to a strafe when holding ZL or aiming a bow.

Warning

Unreal does not handle switching from Orient to Movement into Strafing
To remove the snapping, handle the change via a dedicated function and interpolate the rotation over x seconds

Note

bUseControllerRotationYaw overrides bUseControllerDesiredRotation and bOrientRotationToMovement
bOrientRotationToMovement overrides bUseControllerDesiredRotation
Instead of toggling these, make a function that sets the rotation type you want, which handles setting these properties appropriately

Setting Actor Rotation

Caution

The character's rotation should only update from UCharacterMovementComponent::PhysicsRotation() or ACharacter::FaceRotation()
Move combining will cull any external function call to modify the character's rotation

You can test this quite easily. Simply use Tick() to call AddLocalRotation and assign Yaw as DeltaTime * 45.f.

MoveCombining occurs by default when FPS exceeds 60fps. If your FPS is below this value you will not see the issue. MoveCombining also does not occur in standalone.

PIE as a Client. Your character will be spinning. Your FPS must be over 60. Now use the console command p.NetEnableMoveCombining 0 to disable MoveCombining, and watch as the rotation rate doubles. This is because your saved moves were playing out, getting reverted, combined, then replayed - nullifying half of your calls to modify the actor's rotation.

If you were to add visualization for the server's direction, you would see it rotating at double the rate.

The Solution

How you solve this is quite project dependent, but effectively you need to add your rotation event (e.g. knockback) to your saved moves, and handle SetInitialPosition(), CombineWith(), and possibly PostUpdate(). Of course you might also require PrepMoveFor(), SetMoveFor() and anything else your specific system requires.

Your event should toggle a flag that is set immediately but with no effect, and then the effect should be applied in UpdateCharacterStateBeforeMovement(), which will then get read during PhysicsRotation() or ACharacter::FaceRotation().

Clone this wiki locally