format
typescript
Animation.Play(name, mode)class: Animation
description
Plays an animation clip named "name" directly without any blending or fading.
By using the Play method, you can play a pre-defined animation at runtime. This method can be used to trigger different actions of a character, such as walking, running, attacking, etc.
parameter
| param_name | type | description |
|---|---|---|
| name | string | The name of the animation clip. |
| mode | AnimationPlayMode | The animation play mode. The default value is AnimationPlayMode.StopSameLayer. |
reture
| type | description |
|---|---|
boolean | Whether the animation clip was played successfully. |
code example
typescript
let obj = new GameObject();
let animation = obj.AddComponent<Animation>(Animation);
animation.Play("clip_name", AnimationPlayMode.StopAll);