Animation.Play Manual     Reference     Scripting  
Scripting > Runtime Classes > Animation
Animation.Play

function Play (mode : PlayMode = PlayMode.StopSameLayer) : bool

function Play (animation : string, mode : PlayMode = PlayMode.StopSameLayer) : bool

Description

Plays animation without any blending.

Play() will start animation with name animation, or play the default animation. The animation will be played abruptly without any blending.

If mode is PlayMode.StopSameLayer then all animations in the same layer will be stopped. If mode is PlayMode.StopAll then all animations currently playing will be stopped.

If the animation is already playing, other animations will be stopped but the animation will not rewind to the beginning.

If the animation is not set to be looping it will be stopped and rewinded after playing.

Play() will return false if animation can't be played (no animation clip or no default animation).

// Plays the default animation
animation.Play ();

// Plays the walk animation - stops all other animations in the same layer
animation.Play ("walk");
// Plays the walk animation - stops all other animations
animation.Play ("walk", PlayMode.StopAll);