How to do it...

To animate the trigger position and create a death trap, follow these steps:

  1. Create an empty object in the scene and name it Trap. It will be a parent object for our moving parts.
  2. Put your models into the scene and parent them to the Trap game object. The models should have descriptive names, for instance, LeftTrap and RightTrap.
  3. Add an Animator component to your Trap game object (the root object of our death trap). Set the Update Mode to Animate Physics.
  4. Go to Window | Animation and open the Animation View.
  5. Create a new Animation Clip by clicking on the Create button.
  6. Select the LeftTrap game object and make sure the record button is pressed (in the upper-left corner of the Animation View).
  7. Move the LeftTrap game object ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.