API

Class RootMotionClip

The root motion of an animation group: how far the clip carries the character over a cycle, and how far it turns it, so that the character can be moved by it and its feet stay planted instead of skating.

The clip is analyzed once, when the RootMotionClip is created, without playing the group or changing it:

  1. The root node's own animation is tried first, as the ground truth. If the root ends a cycle a meaningful distance from where it started, that travel is the root motion. Turning is read from the root the same way.
  2. Otherwise the clip is treated as an in-place cycle and the travel is deduced from its contact nodes: a planted contact stays put in the world, so in character space it moves opposite to the character, and whatever it gives up the character gains. The direction of travel falls out of the same measurement, so the forward axis of the rig does not have to be known.

The source group is never changed. The clip owns RootMotionClip.animationGroup, a clone of the source in which the root's travel and turning are left out, so it plays and loops in place: play that group, and give the clip to the RootMotionController of the character so the motion is applied to the character node instead.

const walk = new RootMotionClip(walkGroup);
const controller = new RootMotionController(walk.characterNode, [walk]);
walk.animationGroup.start(true);

The in-place group is a group of the scene, not of the source's asset container, so dispose the clip when it is done with; disposing the container does not. To play a clip additively, build it from the source as it is and make the in-place group additive: AnimationGroup.MakeAnimationAdditive(clip.animationGroup, { referenceFrame: 0 }), with IRootMotionClipOptions.cloneAnimations set so the source keeps its keys.

Implements

Index
  • get fromFrame(): number

    The first frame of the range the clip is analyzed over: the group's range, with a bound outside the clock channel's keys replaced by that channel's first or last key, as playback does.

    Returns number

  • Removes the clip from its controller and disposes the in-place animation group. The source group is untouched. When the in-place group animates the root's position although the source does not (a root that only turns), the root's position is put back to what it was when the clip was created.

    Returns void

  • Gets the turn reached at a frame of the clip about the up axis, relative to its first frame, in radians.

    Parameters

    • frame: number

      defines the frame to sample

    Returns number

    the turn in radians