Controls the playback of animations using a state machine architecture.

The AnimatorController manages animation states, transitions between states, and parameters that affect those transitions. It is used by the Animator component to control animation behavior on 3D models.

Use the static method AnimatorController.createFromClips to create an animator controller from a set of animation clips.

Constructors

Properties

animator?: Animator

The Animator component this controller is bound to.

model: AnimatorControllerModel

The data model describing the animation states and transitions.

normalizedStartOffset: number = 0

The normalized time (0-1) to start playing the first state at. This affects the initial state when the animator is first enabled.

Accessors

  • get activeState(): undefined | State

    Gets the currently active animation state.

    Returns undefined | State

    The active state or undefined if no state is active

  • get context(): undefined | null | Context

    Gets the engine context from the bound animator.

    Returns undefined | null | Context

  • get currentAction(): null | AnimationAction

    Gets the animation action currently playing.

    Returns null | AnimationAction

    The current animation action, or null if no action is playing

Methods

  • Binds this controller to an animator component. Creates a new animation mixer and sets up animation actions.

    Parameters

    • animator: Animator

      The animator to bind this controller to

    Returns void

  • Creates a deep copy of this controller. Clones the model data but does not copy runtime state.

    Returns null | AnimatorController

    A new AnimatorController instance with the same configuration

  • Cleans up resources used by this controller. Stops all animations and unregisters the mixer from the animation system.

    Returns void

  • Yields all animation actions managed by this controller. Iterates through all states in all layers and returns their actions.

    Returns Generator<AnimationAction, void, unknown>

  • Finds an animation state by name or hash.

    Parameters

    • name: undefined | null | string | number

      The name or hash identifier of the state to find

    Returns null | State

    The found state or null if not found

  • Finds an animation state by name or hash.

    Parameters

    • name: undefined | null | string | number

      The name or hash identifier of the state to find

    Returns null | State

    The found state or null if not found

    Use findState instead

  • Gets a boolean parameter value by name or hash.

    Parameters

    • name: string | number

      The name or hash identifier of the parameter

    Returns boolean

    The boolean value of the parameter, or false if not found

  • Gets information about the current playing animation state.

    Returns null | AnimatorStateInfo

    An AnimatorStateInfo object with data about the current state, or null if no state is active

  • Gets a float parameter value by name or hash.

    Parameters

    • name: string | number

      The name or hash identifier of the parameter

    Returns number

    The float value of the parameter, or 0 if not found

  • Gets an integer parameter value by name or hash.

    Parameters

    • name: string | number

      The name or hash identifier of the parameter

    Returns number

    The integer value of the parameter, or 0 if not found

  • Gets the current state of a trigger parameter.

    Parameters

    • name: string | number

      The name or hash identifier of the trigger parameter

    Returns boolean

    The boolean state of the trigger, or false if not found

  • Checks if the controller is currently in a transition between states.

    Returns boolean

    True if a transition is in progress, false otherwise

  • Plays an animation state by name or hash.

    Parameters

    • name: string | number

      The name or hash identifier of the state to play

    • layerIndex: number = -1

      The layer index (defaults to 0)

    • normalizedTime: number = Number.NEGATIVE_INFINITY

      The normalized time to start the animation from (0-1)

    • durationInSec: number = 0

      Transition duration in seconds

    Returns void

  • Resets the controller to its initial state.

    Returns void

  • Resets a trigger parameter to inactive (false).

    Parameters

    • name: string | number

      The name or hash identifier of the trigger parameter

    Returns void

  • Sets a boolean parameter value by name or hash.

    Parameters

    • name: string | number

      The name or hash identifier of the parameter

    • value: boolean

      The boolean value to set

    Returns void

  • Sets a float parameter value by name or hash.

    Parameters

    • name: string | number

      The name or hash identifier of the parameter

    • val: number

      The float value to set

    Returns boolean

    True if the parameter was found and set, false otherwise

  • Sets an integer parameter value by name or hash.

    Parameters

    • name: string | number

      The name or hash identifier of the parameter

    • val: number

      The integer value to set

    Returns void

  • Set the speed of the animator controller. Larger values will make the animation play faster.

    Parameters

    • speed: number

    Returns void

  • Sets a trigger parameter to active (true). Trigger parameters are automatically reset after they are consumed by a transition.

    Parameters

    • name: string | number

      The name or hash identifier of the trigger parameter

    Returns void

  • Updates the controller's state machine and animations. Called each frame by the animator component.

    Parameters

    • weight: number

      The weight to apply to the animations (for blending)

    Returns void

  • Creates an AnimatorController from a set of animation clips. Each clip becomes a state in the controller's state machine.

    Parameters

    • clips: AnimationClip[]

      The animation clips to use for creating states

    • options: CreateAnimatorControllerOptions = ...

      Configuration options for the controller including looping behavior and transitions

    Returns AnimatorController

    A new AnimatorController instance

MMNEPVFCICPMFPCPTTAAATR