How do I rotate a character with root motion?

I posted this in the forums but got nothing, so I’m hoping someone here can tell me what I’m doing wrong.

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 verify this rotation is there in the animation viewer when I turn Root Motion off). 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). Translation is applied fine always.

There are 3 options that look relevant to me 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 with animation successfully.

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.

Anyone know what I’m missing?

1 Like

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).

1 Like

Thanks so much for posting your answer. =)

1 Like

This is exactly what I was looking for.

1 Like

This saved me a good few hours. Thanks!

1 Like

You are just wonderful! :slight_smile: Thanks!

1 Like

Great! That helped ! Thanks.

1 Like

Hey, thanks so much for that!

1 Like