To create an appear animation, follow these steps:
- Import your animated character with Idle and Appear animations.
- Make sure to check the Idle animation's Loop Time option.
- Place the imported character in the scene.
- Create a new Animator Controller and call it Appear (or you can edit an existing controller).
- Drag and drop your Appear animation into the controller and make sure it is the default state. If not, right-click on it and choose the Set As Layer Default State option.
- Drag and drop your Idle animation into the controller.
- Create one transition:
- Appear | Idle with no conditions: Has Exit Time should be set to true and Transition Duration set to 0.2 seconds.
- Assign the Animator Controller to the character standing on the scene (to its Animator component).
- To better see the Appear animation in action, create a prefab from the character. To do so, drag and drop it from the Hierarchy to any folder in the Project View.
- Delete the character from the Hierarchy and write a script to spawn (instantiate) the character in runtime. In this recipe, we use the Spawner.cs script from the example Unity project's Shared Scripts directory.
- This script spawns a prefab (a list of prefabs) in the same position and with the same rotation as the Spawner game object (the object the Spawner.cs script is attached to).