Animating Zombies: Root Transforms

Hal Brooks
3 min readDec 18, 2021

Objective: Add an animated zombie enemy using root motion.

Download Zombie_06 from GameDevHQ Filebase and import into the project. Select the Zombie 6.fbx file and set the animation type to Humanoid, as shown.

Now drag Zombie 6 into the scene and rename to Zombie_Enemy. Make sure the Zombie_Enemy has an Animator, Character Controller, Enemy and Health Scripts attached. These have been described in previous articles, although the Enemy script will be modified.

Component set up for Zombie_Enemy.

Download form Adobe Mixamo animations for Zombie Idle, Zombie Attack and Zombie Walk. Select each xbot file and set the rig animation type to humanoid then duplicate their respective animations. Now drag Zombie Idle copy onto the Zombie_Enemy to create its animator. Repeat this process for Zombie Walk and Zombie Attack. Open the animator window and drag the copies of other two zombie animations for walk and attack into the animator. Add transitions to and from Idle and Walk and Idle and Attack. Also add a transition from Walk to Attack. Now add two trigger parameters Chase and Attack.

Zombie_Enemy animator with idle, walk and attack animations.

The Walk -> Attack and Idle -> Walk transitions are set up as shown below, using the Attack trigger to switch to Attack animation. Uncheck has exit time and set transition duration to 0. Both Walk -> Idle and Attack -> Idle have has exit time checked with set transition duration to 0.

Walk -> Attack transition setup.

Now select the Zombie Walk animation in the project window. This animation needs to use the transform root animation position (XZ) to move the zombie. This allows the animation to move the zombie, instead of using the controller to move along the XZ plane. This is important, because the zombie has an irregular gait. Bake into pose the Rotation and Position (Y) into pose based on original work Walk animation. Similarly set up the Idle and Attack, except bake into pose the root transform position (XZ).

Set up Zombie Walk animation to use root transformation (XZ).

The EnemyMove() is altered to move the Zombie_Enemy by triggering the animation‘s root transform (XZ) movement using the Chase trigger on the Animator, i.e. _anim. The transform.LookAt the lookPos directs this motion towards the Player. The lookPos.y is set to the zombie’s current position.y to prevent upward or downward rotation of the model. If CharacterController.Move were used a sliding effect for the zombie’s walk would be observed, which is unrealistic.

EnemyMove() on Enemy script

Finally modify the EnemyAttack() method on the Enemy script activate the Attack trigger in the Animator or _anim.

EnemyAttack() method in Enemy script.

--

--