Getting ready

To use root motion, first you need to create a character with a walk or run animation, that has translation in it; see the following screenshot:

Frames of a run animation using root motion. The character is animated with root node translation

If you are using a Humanoid character, the hip bone is used as the root node, the one describing root motion. So hip translation will describe the translation of the character in game (you can still have motion in the Y axis as we can then adjust it in the Import settings). Its rotation will describe character rotation in the game. If you are using a Generic character, you need to choose the Root Node manually in the Import settings. Select the model, go to Inspector, click on the Rig tab, set the Animation Type to Generic, and select the Root Node from its drop-down menu (it contains the whole bone hierarchy of your rig).

You can also download the provided example Unity project and go to Chapter 04 Character movementRecipe 02 Using root motion to drive rigid body characters movement with animations directory. You will find a scene called Example.unity there, with a Humanoid game object in the Hierarchy.

If you play the game, you can move the character with WSAD or the arrow keys and run with Shift. The movement is described by root motion, but steering is done with scripts (we simply rotate the character). In the Rigs directory, you can find the imported Humanoid.fbx file with all the required animations.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.70.21