Creating an elevator triggered by player input
In this last recipe, we will use player input to create a simple elevator.
Getting ready
Before we start, you should prepare an elevator model to contain the objects: the root object called Elevator, the Lift object (this one will be animated), and the ElevatorFrame object, which will work as decoration. The Lift and ElevatorFrame objects should be children of the empty Elevator object. You can also use the example Unity project provided and go to the Chapter 02 Working with the animation view\Recipe 07 Creating an elevator triggered by player input directory. You will find an Example.unity scene there with the Elevator game object and its children Lift and ElevatorFrame objects. The Elevator is already animated in the example assets.
How to do it...
To create an elevator triggered by player input, follow these steps:
- Select the root
Elevatorobject and assign an Animator component to it. Set theUpdate ModetoAnimate Physics. - Open
Window | Animation...