Play animations in your scene
Play animations in your scene either automatically or in response to buttons or Logic scripts.
Read time 2 minutesLast updated 4 hours ago
You can start the animations you create with the Animation Director and Animation component in several ways:
- Play an animation automatically
- Use a button to play the animation
- Set up a Logic script to play the animation
Play an animation automatically
Autoplay starts an animation automatically when the Animation component or Animation Director becomes active. By default, this happens when the scene starts, unless you disable the object or component. If the object is inactive when the scene loads, the animation doesn’t start until you enable the object later. To play an animation when the scene starts:- Select the Animation Director or the object that contains the Animation component in the Hierarchy panel. The Inspector panel displays.
- In the Inspector panel, enable Active (the checkbox next to the object's name) to ensure the object is active on start.
- If your animations aren't already set up on the object:
- Select Add (+) to add animations or timelines.
- Configure the remaining settings as needed. Refer to Animation component reference or Animation Director reference for information about these settings.
- Set Autoplay to the animation or timeline you want to play automatically.
- Press Play.
Use a button to play the animation
Buttons provide an alternative way to trigger an animation in your scene without the need to set up separate Logic scripts. The animation starts when the user interacts with the button. To set up a button to play an animation:- Select a Button object in the Hierarchy panel. If there are no buttons, select Add (+) > UI > Button to add one.
- In the Inspector panel, enable Interactable.
- Navigate to the When button is clicked section of the button's properties.
- Select Add (+) to add an animation section to your button.
- Expand the dropdown and select either the Animation Director or an object that contains an Animation component.
- Choose an action (Play, Pause, Stop).
- If shown, set Name to the animation clip you want to trigger.
- Optionally, set Speed to change the playback speed of the animation.