The animation component is used to play back animations.
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 AnimationStates is performed like this:
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; } } }
Additional resources: An overview of animation scripting in Unity is here.
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? |
localBounds | AABB of this Animation animation component in local space. |
playAutomatically | Should the default animation clip (the Animation.clip property) automatically start playing on startup? |
this[string] | Returns the animation state named name. |
updateMode | Specifies the update mode of the Animation. |
wrapMode | How should time beyond the playback range of the clip be treated? |
AddClip | Adds a clip to the animation with name newName. |
Blend | Blends the animation named animation towards targetWeight over the next time seconds. |
CrossFade | Fades in the animation with the name animation over a period of time defined by fadeLength. |
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 name playing? |
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 the animation named name. |
Sample | Samples animations at the current state. |
Stop | Stops all playing animations that were started with this Animation. |
enabled | Enabled Behaviours are Updated, disabled Behaviours are not. |
isActiveAndEnabled | Reports whether a GameObject and its associated Behaviour is active and enabled. |
gameObject | The game object this component is attached to. A component is always attached to a game object. |
tag | The tag of this game object. |
transform | The Transform attached to this GameObject. |
hideFlags | Should the object be hidden, saved with the Scene or modifiable by the user? |
name | The name of the object. |
BroadcastMessage | Calls the method named methodName on every MonoBehaviour in this game object or any of its children. |
CompareTag | Checks the GameObject's tag against the defined tag. |
GetComponent | Gets a reference to a component of type T on the same GameObject as the component specified. |
GetComponentInChildren | Gets a reference to a component of type T on the same GameObject as the component specified, or any child of the GameObject. |
GetComponentInParent | Gets a reference to a component of type T on the same GameObject as the component specified, or any parent of the GameObject. |
GetComponents | Gets references to all components of type T on the same GameObject as the component specified. |
GetComponentsInChildren | Gets references to all components of type T on the same GameObject as the component specified, and any child of the GameObject. |
GetComponentsInParent | Gets references to all components of type T on the same GameObject as the component specified, and any parent of the GameObject. |
SendMessage | Calls the method named methodName on every MonoBehaviour in this game object. |
SendMessageUpwards | Calls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour. |
TryGetComponent | Gets the component of the specified type, if it exists. |
GetInstanceID | Gets the instance ID of the object. |
ToString | Returns the name of the object. |
Destroy | Removes a GameObject, component or asset. |
DestroyImmediate | Destroys the object obj immediately. You are strongly recommended to use Destroy instead. |
DontDestroyOnLoad | Do not destroy the target Object when loading a new Scene. |
FindAnyObjectByType | Retrieves any active loaded object of Type type. |
FindFirstObjectByType | Retrieves the first active loaded object of Type type. |
FindObjectsByType | Retrieves a list of all loaded objects of Type type. |
Instantiate | Clones the object original and returns the clone. |
bool | Does the object exist? |
operator != | Compares if two objects refer to a different object. |
operator == | Compares two object references to see if they refer to the same object. |