Skip to content

Animator

extends Component

The Animator class is used to manage complex animation state machines and transitions. The Animator component is used to control the playback and management of animations for characters or objects.

You can obtain the Animator component in the following way:

typescript
let obj = new GameObject();
let animator = obj.AddComponent<Animator>(Animator);

成员变量

Animator.animatorData : AnimatorData
Controls the animator resource.
Animator.speed : number
The playback speed of the animator. 1 is the normal playback speed.
Animator.cullMode : AnimationCullMode
Controls the culling of this Animator component.

成员方法

Animator.CrossFade ( name : string , normalized_transition_duration : number , layer_index : number? , normalized_time_offset : number? , normalized_transition_time : number? ) : void
Performs a smooth transition between the current animation state and the target animation state.
Animator.CrossFadeInFixedTime ( name : string , normalized_transition_duration : number , layer_index : number? , fixed_time_offset : number? , fixed_transition_time : number? ) : void
Transitions from the current animation state to the target animation state within a specified time.
Animator.SetInteger ( name : string , value : number ) : boolean|undefined
Sets the current value of the integer type parameter with the specified parameter name.
Animator.PlayInFixedTime ( name : string , layer_index : number? , fixed_time_offset : number? ) : void
Switches the animation state to the specified animation state and plays it immediately within the specified time.
Animator.Play ( name : string , layer_index : number? , normalized_time_offset : number? ) : void
Switches the animation state to the specified animation state and plays it immediately.
Animator.GetBool ( name : string ) : boolean|undefined
Gets the current value of a boolean parameter with the specified parameter name.
Animator.GetCurrentStateInfo ( layer_index : number ) : AnimatorStateInfo
Get the current state information of an animation in the specified layer and store it in the target animation state information object.
Animator.GetNextStateInfo ( layer_index : number ) : AnimatorStateInfo
Gets the animation state information of the next state within the specified layer and stores it in the target animation state information object.
Animator.GetFloat ( name : string ) : number|undefined
Get the current value of the float type parameter with the specified parameter name.
Animator.GetInteger ( name : string ) : number|undefined
Gets the current value of the integer type parameter with the specified parameter name.
Animator.SetBool ( name : string , value : boolean ) : boolean|undefined
Sets the current value of the specified boolean parameter.
Animator.SetFloat ( name : string , value : number ) : boolean|undefined
Sets the current value of the float type parameter with the specified parameter name.
Animator.SetTrigger ( name : string ) : boolean|undefined
Set the value of the specified trigger parameter by its name.
Animator.ResetTrigger ( name : string ) : boolean|undefined
Reset the value of the specified trigger parameter.