Rotating character using root motion

Hi there, I’m having trouble rotating my character in a side-scroller. I’ve worked around this problem for a long time by applying yaw procedurally to my character (with CharacterMovementComponent:Use Controller Desired Rotation enabled), but now I’d really like to fix things so root motion through animation can take over (like all other movement is controlled in my game).

In my side-scroller the character moves in positive or negative X. I have an animation that rotates the root bone of the hierarchy 180 degrees around Z (I can see this rotation in the animation viewer when I turn Root Motion off to verify). I play this animation whenever I know my character needs to turn around. The rotation never seems to get applied to the character globally, so my character keeps turning on the spot and resetting to the direction they were facing at the start of the animation (as though I didn’t have root motion enabled, even though I definitely do).

There are 3 options that look relevant in CharacterMovementComponent:

Orient Rotation To Movement
Use Controller Desired Rotation
Constrain to Plane (set to a plane in X)

In my procedural workaround I had all options set to true, and applying yaw would make the character rotate on the spot until they aligned with the required direction.

With my attempt at root motion rotation, no combination of the above options makes the character rotate successfully.

Anyone know what I’m missing?

It also appears that if I teleport the player with a new orientation, it doesn’t work in any case. Something is forcing my character’s orientation to be stuck and the only way to change it is by applying yaw.

So after poking around in code for a bit I’ve found what it was: bUseControllerRotation Pitch/Yaw/Roll.

In my player blueprint, which inherits from Character, bUseControllerRotationYaw is defaulted to true (basic Pawn’s have it defaulted to false). When bUseControllerRotationYaw is true, any animated or set rotation is ignored and only FRotator APlayerController::ControlRotation is used (which can be affected by applying yaw input).

I’ll now switch bUseControllerRotationYaw on and off dynamically depending on my use cases (off most of the time, on when I don’t have an animation that performs the required rotation).

It’s disappointing that the use of this bool isn’t documented alongside root motion tutorials/docs, because root translation (which works out of the box) behaves very differently to root rotation by default (which doesn’t).