Animate a GameObject with the Animation component
Instructions on how to use the Animation component to animate a GameObject.
Read time 1 minuteLast updated 2 days ago
Use the Animation component to add animations to a GameObject and its children in your scene.
Add an Animation component to a GameObject
- Select the GameObject you want to animate in your scene.
- Open the Inspector Panel.
- Select Add Component and choose Animation. The Animation Tool window opens.
Create an animation
- Move the cursor on the timeline to the moment you want to set a keyframe.
- Make a change to your GameObject. A keyframe is automatically created.
- Drag keyframes on the timeline to adjust the timing and duration of your animation. Move a keyframe onto another keyframe to merge them. You can select multiple keyframes by holding left-click and dragging a selection box around them. When in multi-select mode, keyframes can't be merged.
- Add more keyframes to create longer or more detailed animations. You can delete a keyframe by selecting it and pressing the Delete key on your keyboard.
- Press the Play button in the Animation Tool window to preview your animation.
Examples
Use case | Description |
---|---|
Visual effects | Change the material color to create effects, like a blinking or pulsing object. |
Trigger animations with Logic scripts | Use Lite Logic to play, pause, or stop animations at specific moments in your application. For example, you might play an animation when a certain event happens. |
Trigger animations with Button On Click | Set up a button to trigger an animation directly when the user clicks it. In the button’s settings, add an action under When the button is clicked, select the GameObject, and choose the animation to play, pause, or stop. For more information, refer to Button. |