My journey becoming a Unity game developer: Player Movement-Setup the Animation Behavior Tree

Rhett Haynes
3 min readOct 27, 2021

--

Objective: Setup the Idle and Walk animations for Darren in the Animator by transitioning the animations using an Animation Behavior Tree.

In the Animator, we will start by creating transitions between the Idle and Walk animations. Right-click on the Idle animation, select Make Transition and move the arrow onto the Walk animation. Make another transition from the Walk animation to the Idle animation by right-clicking on Walk and placing the arrow onto the Idle animation. Now we’re setup to transition between the animations and next is to create a way to activate one animation from the other.

Making transitions from Idle to Walk and vice versa with a Bool parameter created for the transitions.

Over in the Parameters tab on the left, create a new Bool condition to check and name it Walk. Click on the transition’s arrow from Idle pointing towards Walk and head over into the Inspector. We want to uncheck the Has Exit Time box to allow the player to go into one animation from the other without having to wait for the animation clip to play completely before doing so. Under the Conditions setting, create a new condition with Walk = true by clicking the “+” sign. Do the same thing with the transition between Walk pointing towards Idle, but the Condition setting will be Walk = false instead to go back from walking to being idle.

Setting the transitions Bool condition to True or False when these animations are played.

To see the animations playing for Darren, there is a Preview pane down below. If you don’t see Darren in the window, drag the Darren 3D model prefab into the Preview pane and when you see Darren there, just click on the Play button to preview Darren’s new animations playing.

Dragging in the Darren 3D model into the Preview pane to view the animations of Idle and Walk.

Now when we play the game, Darren is going to be moving around the Auction room in his Idle animation since this is his Default animation.

Darren moving around in his Idle animation.

Now when we activate the Walk bool parameter, we will see Darren moving around the room walking instead of sliding around. Also, Darren’s Walk animation will keep on playing until the Walk parameter is turned off. The best way to manipulate the Walk parameter on and off will be through code.

Darren moving around in his Walk animation.

Last thing we need to check out is the error message that keeps popping up when the Walk animation is playing. This error message is about an Event trigger assigned in the Walk animation clip that is missing the game object. We’re not using an Event trigger at this moment, so to delete the Event we will double-click on the Walk animation clip itself to open the Animation tab with the Walk animation displayed in the editor. At the top of the timeline we will see 2 bars placed at specific times in the timeline. Just click on each one and press Delete to remove them permanently.

Animation Event deleted from the Walk animation clip to prevent this error.

--

--

Rhett Haynes
Rhett Haynes

Written by Rhett Haynes

Learning to become a Unity game developer.

No responses yet