Class RootMotionController
Implements
Constructors
constructor
-
new RootMotionController(
characterNode: TransformNode,
clips?: RootMotionClip[],
): RootMotionControllerCreates a controller for a character node.
Parameters
- characterNode: TransformNode
defines the node to move: the character node of the clips
- clips: RootMotionClip[] = []
defines the clips to add
Returns RootMotionController
- characterNode: TransformNode
Properties
apply To Character
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.
Readonlyon Root Motion Observable
Notified every animation step the clips produce motion, after RootMotionController.deltaPosition and RootMotionController.deltaRotation are updated.
Accessors
character Node
-
The node the motion is applied to.
Returns TransformNode
clips
-
The clips whose motion moves the character.
Returns readonly RootMotionClip[]
delta Position
-
The travel of the last animation step, in world space; applied to the character unless RootMotionController.applyToCharacter is false.
Returns Vector3
delta Rotation
-
get deltaRotation(): number
The turn of the last animation step about the up axis, in radians; applied to the character unless RootMotionController.applyToCharacter is false.
Returns number
Methods
add Clip
-
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
- clip: RootMotionClip
dispose
-
Stops applying the motion and lets the clips go. The clips and their groups are not disposed.
Returns void
remove Clip
-
Removes a clip. Its in-place group keeps playing, in place.
Parameters
- clip: RootMotionClip
defines the clip
Returns void
- clip: RootMotionClip
reset
-
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
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.