Monday, October 15, 2018

3D Animations 2 / 2

This time we'll make our tiger walk around. To do that, we are going to make TigerAnimator blend 'idle' and 'walk' animations based on new 'Speed' parameter.

Lets add 'Speed' parameter to our TigerAnimator first.

Then, we should rename our 'idle' state to 'locomotion', and make a blend tree in it.

Double click on 'locomotion' state, it will open our newly created blend tree in animator window. Add 'idle' and 'walk' animations too it. Make sure that Parameter is set to 'Speed'.

We need to change our Tiger.cs script to use 'Speed' parameter. Open it and modify Update method like this.

Now our tiger should walk forward when we press up arrow or 'w' key

What happens when we go backwards though? Our tiger just slides back, that's no good... We don't have 'walk backwards' animation, however, we can just use normal walk animation and play it in reverse. Go back to our blend tree, add 'walk' animation again and set thresholds and speed like here.

Now our tiger can walk backwards! Another small issue is that when we press Fire1 while holding up or down keys, our tiger slides around while roar animation plays. Lets make our tiger stop before roaring. To do that, we have to update our Tiger.cs script again. As a finishing touch, we will also add turning.

Congratulations! You now have animated game character who can walk around and roar at things!

No comments:

Post a Comment