Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

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

Animator.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(stateName: string, layer: int = -1, normalizedTime: float = float.NegativeInfinity): void;
public void Play(string stateName, int layer = -1, float normalizedTime = float.NegativeInfinity);
public function Play(stateNameHash: int, layer: int = -1, normalizedTime: float = float.NegativeInfinity): void;
public void Play(int stateNameHash, int layer = -1, float normalizedTime = float.NegativeInfinity);

Parameters

stateName The name of the state the will be played.
layer The layer where the state is. If no layer is specified or layer is -1, the first state that is found with the given name or hash will be played.
normalizedTime The normalized time at which the state will play. If no explicit normalizedTime is specified or normalizedTime value is float.NegativeInfinity, the state will either be played from the start if it's not already playing, or will continue playing from its current time.
stateNameHash The hash of the state. Passing zero will play the current state.

Description

Plays a state.

This could be used to synchronize your animation with audio or synchronize an Animator over the network.