O'Reilly logo

Unity 2D Game Development Cookbook by Claudio Scolastici

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Coding the Boolean-based transitions

With the transition between Idle and Jump configured in the Animator window, we can script a piece of code to trigger it. With the following recipe, we show how simple it is to control animations through scripting with Unity.

Getting ready

As usual, we follow on from the last recipe. You just need to add a C# script in the Scripts folder of the project (as you learned in Chapter 2, Importing 3D Graphics) and name it Char_Animator.

How to do it...

  1. Access the Scripts folder in your Project panel and double-click on the newly created script to open it in Monodevelop, the default Unity script editor.
  2. Let's begin by creating an Animator type variable to store the reference to the character animator and add the following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required