API

Class RootMotionController

Moves and turns a character node by the root motion of the clips playing on it, once per animation step - from the scene's onAfterAnimationsObservable, so after animations are evaluated and before the world matrices are computed.

The motion of each clip follows the playback of its in-place group's root animation: the progress of the pose it evaluated, so pausing, speed ratio changes, looping in every loop mode, forwards and backwards, playing a range, synchronizing with another animatable and running to the end all move the character exactly as far as the pose went. Clips playing together are blended the way the animation mixer blends their root pose: weighted animation groups contribute their share, normalized once their weights add up to more than one, additive groups add theirs on top, an unweighted group contributes its whole pose only while no weighted group animates the root (among unweighted groups the last to write wins), and a group blending in contributes as much as it is blended in, so the character moves with the blended pose whatever the clips do. The turn is blended as a weighted sum of the clips' turns.

const controller = new RootMotionController(character, [walk, run]);
walk.animationGroup.start(true);
run.animationGroup.start(true);
walk.animationGroup.weight = 0.3;
run.animationGroup.weight = 0.7;

Implements

Index
applyToCharacter: boolean = true

Gets or sets whether the motion is applied to the character node every frame. Set it to false to consume RootMotionController.deltaPosition and RootMotionController.deltaRotation yourself, for example to drive a physics character controller.

onRootMotionObservable: Observable<RootMotionController> = ...

Notified every animation step the clips produce motion, after RootMotionController.deltaPosition and RootMotionController.deltaRotation are updated.

  • Adds a clip, so the character moves while its in-place group plays.

    Parameters

    • clip: RootMotionClip

      defines the clip; its character node must be the controller's

    Returns void

    when the clip belongs to another controller, moves another node, or has another up axis than the clips already added

  • Forgets where the playbacks were last measured. Call after jumping a group with goToFrame or resetting it, so the jump is not read as motion. Starting a group again needs no reset.

    Returns void