Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Animation

The animation component is used to play back animations.
Read time 7 minutesLast updated 5 days ago

Definition

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 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.

Properties

Property

Description

animatePhysicsWhen enabled, the physics system uses animated transforms from GameObjects with kinematic Rigidbody components to influence other GameObjects.
clipThe default animation.
cullingTypeControls culling of this Animation component.
isPlayingIs an animation currently being played?
this[]Returns the animation state named
name
.
localBoundsAABB of this Animation animation component in local space.
playAutomaticallyShould the default animation clip (the Animation.clip property) automatically start playing on startup?
updateModeSpecifies the update mode of the Animation.
wrapModeHow should time beyond the playback range of the clip be treated?

Methods

Method

Description

AddClipAdds a
clip
to the animation with name
newName
.
BlendBlends the animation named
animation
towards
targetWeight
over the next
time
seconds.
CrossFadeFades in the animation with the name
animation
over a period of time defined by
fadeLength
.
CrossFadeQueuedCross fades an animation after previous animations has finished playing.
GetClipCountGet the number of clips currently assigned to this animation.
IsPlayingIs the animation named
name
playing?
PlayPlays an animation without blending.
PlayQueuedPlays an animation after previous animations has finished playing.
RemoveClipRemove clip from the animation list.
RewindRewinds all animations.
SampleSamples animations at the current state.
StopStops all playing animations that were started with this Animation.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.