Skip to content

format

typescript
Animation.CrossFadeQueued(name, normalized_duration, queue_mode, mode)

class: Animation

description

Cross-fades the animation after the previous animation has finished playing.

For example, you may want to play animations one after another in a specified sequence. The animation will self-replicate before playing, so you can cross-fade between the same animation. This can be used to override two identical animations. For example, you may have a sword swinging animation. After the player swings the sword back and forth, they quickly make two powerful strikes. You can play the animation in reverse, starting from the beginning, but you will see frame skipping after that.

parameter

param_nametypedescription
namestringThe name of the animation to play.
normalized_durationnumberThe duration of the cross-fade in and out (in seconds).
queue_modeAnimationQueueModeThe queue mode for playing the animation.
modeAnimationPlayModeThe mode for playing the animation.

reture

typedescription
AnimationStateThe animation state.

code example

typescript
let obj = new GameObject();
let animation = obj.AddComponent<Animation>(Animation);
let uuid = "31A9092E1264B19BBFD9D5FCD75AA49";
let clip = Resources.Load<AnimationClip>(AnimationClip, uuid);
animation.CrossFadeQueued(clip.name, Math.random(), AnimationQueueMode.CompleteOthers, AnimationPlayMode.StopAll);