Mirror animation in Human IK with root motion

Our goal is to swap animation between left and right sides of the body. For example there is a walk forward start animation that begins by lifting the left foot, and we want the exact opposite: character walks forward but starts by lifting the right foot. In my case it’s for UE4 character with root motion, but I suppose it can be applied to another cases too.

Basically, it’s pretty easy: you take the skeleton in appropriate pose (T-pose), duplicate it and create 2 HIK characters, let’s call them “source” and “mirror”. I also moved the mirror skeleton to another namespace, to avoid problems when importing animation later.

Then in the HIK attributes of the mirror character you set retarget specific attribute “mirror animation” to “on”. Then you set HIK Character to “mirror” and source to “source” and voila, your character is mirrored. You can import animation in the root namespace and it will be mirrored. Finally, you have to bake and export it.

The problem is that the root bone is not retargeted by Human IK. Root bone will not move and the rest of the body will look in the opposite direction. Root motion will be transferred to pelvis.

To fix this we create two intermediate objects (locators) called pseudo_root and pseudo_pelvis. Align them to mirrored root and pelvis. The mirrored root is then parent constrained to pseudo_root and mirrored pelvis to pseudo_pelvis. Pseudo_pelvis replaces pelvis in the HIK definition of mirrored character. Pseudo_root moves like the opposite of the original root (copy and modify transform using node editor).

To summarize: HIK will drive pseudo_pelvis which will drive mirrored pelvis; and mirrored root will be driven by pseudo_root which will move like the opposite of the original root. Both will look in the same direction, like it should be.

Next step, disable the mirrored root constraint and bake the animation to skeleton (from HIK menu). Select all bones in the mirrored skeleton except root and pelvis, and also select pseudo_pelvis.

Next step, re-enable pseudo_root constraint. Now pelvis is driven by baked pseudo_pelvis and root is driven by the node editor. This way they are both in right places. Bake root and pelvis and disable constraints. Done. Export and rotate by 180° when importing in Unreal.

Pseudo_root and pseudo_pelvis are needed to avoid double transform. I hope there is a simpler way, but I didn’t found one. Also, there is a problem transferring twist bones using HIK, I didn’t find any solution, just skipped them.

2 thoughts on “Mirror animation in Human IK with root motion

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s