Animating object's local position - creating automatic doors
In this recipe, we will learn how to animate an object's local position to be able to use the same animated object in multiple locations in the scene. We will create another common gameplay mechanism, automatic door, as an example.
Getting ready
To make an animated door, you should have two objects ready: the Door Frame and the Door. The Door should be a child of the Frame in the Hierarchy. It should be placed in the closed position. We assume that our Door will slide upward when opening. You should also have a player character with the Player tag assigned. The character should use a Rigidbody component to move or have a kinematic Rigidbodycomponent. We will use triggers for our doors, and triggers react to Rigid bodies only. You can also go to the Chapter 02 Working with the animation view\Recipe 04 Animating objects local position - creating automatic doors directory and find the Example.unity scene there. If you open it, you...