Legacy Documentation: Version 5.0
Language: English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Animation.Play

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public function Play(mode: PlayMode = PlayMode.StopSameLayer): bool;
public bool Play(PlayMode mode = PlayMode.StopSameLayer);
public function Play(animation: string, mode: PlayMode = PlayMode.StopSameLayer): bool;
public bool Play(string animation, PlayMode mode = PlayMode.StopSameLayer);

Parameters

Description

Plays an animation without any blending.

If no name is supplied then the default animation will be played. In cases where the animation can't be played (ie, there is no default animation or no animation with the specified name), the function will return false.

The optional playMode lets you choose how this animation will affect others already playing.

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

When the end of the animation is reached it will automatically be stopped and rewound to the start unless the PlayMode is set to Loop.