Animation
The animation component is used to play back animations.
Read time 7 minutesLast updated 4 days ago
Definition
- Type: Class
- Namespace: UnityEngine
- Assembly: UnityEngine.AnimationModule
- Inherits from: Behaviour
- Implements: IEnumerable
public sealed class Animation : Behaviour, IEnumerable
Remarks
You can assign animation clips to the animation component and control playback from your script. The animation system in Unity is weight-based and supports Animation Blending, Additive animations, Animation Mixing, Layers and full control over all aspects of playback.
For an overview of animation scripting in Unity please read this introduction.
AnimationState can be used to change the layer of an animation, modify playback speed, and for direct control over blending and mixing.
Also Animation supports enumerators. Looping through all AnimationState is performed like this:
Additional Resources: here
Examples
using UnityEngine;using System.Collections;public class ExampleClass : MonoBehaviour{ public Animation anim; void Start() { anim = GetComponent<Animation>(); foreach (AnimationState state in anim) { state.speed = 0.5F; } }}
Properties
Property | Description |
|---|---|
| animatePhysics | When enabled, the physics system uses animated transforms from GameObjects with kinematic Rigidbody components to influence other GameObjects. |
| clip | The default animation. |
| cullingType | Controls culling of this Animation component. |
| isPlaying | Is an animation currently being played? |
| this[] | Returns the animation state named |
| localBounds | AABB of this Animation animation component in local space. |
| playAutomatically | Should the default animation clip (the _clip property) automatically start playing on startup? |
| updateMode | Specifies the update mode of the Animation. |
| wrapMode | How should time beyond the playback range of the clip be treated? |
Methods
Method | Description |
|---|---|
| AddClip | Adds a |
| Blend | Blends the animation named |
| CrossFade | Fades in the animation with the name |
| CrossFadeQueued | Cross fades an animation after previous animations has finished playing. |
| GetClipCount | Get the number of clips currently assigned to this animation. |
| IsPlaying | Is the animation named |
| Play | Plays an animation without blending. |
| PlayQueued | Plays an animation after previous animations has finished playing. |
| RemoveClip | Remove clip from the animation list. |
| Rewind | Rewinds all animations. |
| Sample | Samples animations at the current state. |
| Stop | Stops all playing animations that were started with this Animation. |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |