A fluent builder for creating AnimatorController instances from code.

Use AnimatorController.build to create a new builder.

const controller = AnimatorController.build("CharacterController")
.floatParameter("Speed", 0)
.triggerParameter("Jump")
.state("Idle", { clip: idleClip, loop: true })
.state("Walk", { clip: walkClip, loop: true })
.state("Jump", { clip: jumpClip })
.transition("Idle", "Walk", { duration: 0.25 })
.condition("Speed", "greater", 0.1)
.transition("Walk", "Idle", { duration: 0.25 })
.condition("Speed", "less", 0.1)
.transition("*", "Jump", { duration: 0.1 })
.condition("Jump", "if")
.transition("Jump", "Idle", { hasExitTime: true, exitTime: 0.9, duration: 0.25 })
.build();

Constructors

Methods

  • Adds a boolean parameter

    Parameters

    • name: string
    • defaultValue: boolean = false

    Returns this

  • Adds a condition to the most recently added transition. Multiple conditions on the same transition are AND-ed together.

    Parameters

    • parameter: string

      Name of the parameter to evaluate

    • mode: ConditionMode

      Condition mode: "if", "ifNot", "greater", "less", "equals", "notEqual"

    • threshold: number = 0

      Comparison threshold for numeric conditions (default: 0)

    Returns this

  • Sets which state is the default/entry state. If not called, the first added state is used.

    Parameters

    • name: string

      Name of the state

    Returns this

  • Adds a float parameter

    Parameters

    • name: string
    • defaultValue: number = 0

    Returns this

  • Adds an integer parameter

    Parameters

    • name: string
    • defaultValue: number = 0

    Returns this

  • Adds a state to the controller. The first state added becomes the default state.

    Parameters

    • name: string

      Unique name for the state

    • options: StateOptions

      State configuration including clip, loop, speed

    Returns this

  • Adds a transition between two states. Use "*" as the source to create a transition from any state. Chain .condition() calls after this to add conditions.

    Parameters

    • from: string

      Source state name, or "*" for any-state transition

    • to: string

      Destination state name

    • Optionaloptions: TransitionOptions

      Transition configuration

    Returns this

  • Adds a trigger parameter

    Parameters

    • name: string

    Returns this