How to do it...

To make a character dodge, follow these steps:

  1. Import the character into Unity and place it in a scene.
  2. If you want the character to get damage and play hit reactions, follow the previous recipe.
  3. Create a new Animator Controller or edit the one from the previous recipe.
  4. Drag and drop the Dodge animation into the controller.
  5. Create a Dodge Trigger parameter in the controller.
  6. Create two transitions:
    • SpiderIdleDodge with one condition: Dodge Trigger parameter. Has Exit Time should be set to false and Transition Duration set to 0.2 seconds.
    • DodgeSpiderIdle with no conditions: Has Exit Time should be set to true and Transition Duration set to 0.2 seconds.
  7. Add a Rigidbody component to the Spider character and freeze its ...

Get Unity 5.x Animation Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.