Engine API Reference - v2.23.0-beta.17
    Preparing search index...

    Class AnimComponentLayer

    An AnimComponentLayer is one layer of an AnimComponent. It runs the state machine that the AnimStateGraph defines for that layer and contributes the result to the entity's final pose with a weight, either overwriting the layers beneath it or adding to them according to blendType. A mask limits which nodes of the hierarchy the layer animates, which is how an upper-body action plays on top of a full-body locomotion layer. The first layer is AnimComponent#baseLayer; add more with AnimComponent#addLayer.

    Playback is per layer: play starts a named state, transition blends to another state over a given time, pause and reset act on the current state, and activeState, activeStateProgress and transitioning report where the layer is. assignAnimation binds an AnimTrack to a state, or to a node inside a blend tree using a dotted path, and blendToWeight fades the whole layer in or out.

    // Fade in an upper-body layer and play its 'Wave' state over the base layer
    const layer = entity.anim.findAnimationLayer('UpperBody');
    layer.blendToWeight(1, 0.3);
    layer.play('Wave');
    Index
    • get activeStateProgress(): number

      Gets the currently active state's progress as a value normalized by the state's animation duration. Looped animations will return values greater than 1.

      Returns number

    • get mask(): any

      Gets the mask of bones which should be animated or ignored by this layer.

      Returns any

    • set mask(value: any): void

      Sets the mask of bones which should be animated or ignored by this layer.

      Parameters

      • value: any

      Returns void

      entity.anim.baseLayer.mask = {
      // include the spine of the current model and all of its children
      "path/to/spine": {
      children: true
      },
      // include the hip of the current model but not all of its children
      "path/to/hip": true
      };
    • Assigns an animation track to a state or blend tree node in the current graph. If a state for the given nodePath doesn't exist, it will be created. If all states nodes are linked and the AnimComponent#activate value was set to true then the component will begin playing.

      Parameters

      • nodePath: string

        Either the state name or the path to a blend tree node that this animation should be associated with. Each section of a blend tree path is split using a period (.) therefore state names should not include this character (e.g "MyStateName" or "MyStateName.BlendTreeNode").

      • animTrack: AnimTrack

        The animation track that will be assigned to this state and played whenever this state is active.

      • Optionalspeed: number

        Update the speed of the state you are assigning an animation to. Defaults to 1.

      • Optionalloop: boolean

        Update the loop property of the state you are assigning an animation to. Defaults to true.

      Returns void

    • Blend from the current weight value to the provided weight value over a given amount of time.

      Parameters

      • weight: number

        The new weight value to blend to.

      • time: number

        The duration of the blend in seconds.

      Returns void

    • Returns an object holding the animation asset id that is associated with the given state.

      Parameters

      • stateName: string

        The name of the state to get the asset for.

      Returns { asset: number }

      An object containing the animation asset id associated with the given state.

    • Start playing the animation in the current state.

      Parameters

      • Optionalname: string

        If provided, will begin playing from the start of the state with this name.

      Returns void

    • Removes animations from a node in the loaded state graph.

      Parameters

      • nodeName: string

        The name of the node that should have its animation tracks removed.

      Returns void

    • Transition to any state in the current layers graph. Transitions can be instant or take an optional blend time.

      Parameters

      • to: string

        The state that this transition will transition to.

      • Optionaltime: number = 0

        The duration of the transition in seconds. Defaults to 0.

      • OptionaltransitionOffset: number = null

        If provided, the destination state will begin playing its animation at this time. Given in normalized time, based on the states duration & must be between 0 and 1. Defaults to null.

      Returns void