Building a State Machine and timing the animations

The last thing to do is set up the state machine and write the code that will make the various animations play.

To hook up the various animations and have them play at the correct time, complete the following steps:

  1. We'll start by creating the state machine that will work as the logic for our animation sequences. Create a new Animator Controller named ChestOpeningStateMachine.controller in Assets/Animations/Controllers.
  2. Open the ChestOpeningStateMachine Animator Controller and create 12 new empty states. Arrange, name, and transition the states, as shown in the following screenshot:

The ...

Get Mastering UI Development with Unity 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.