Class RootMotionClip
Implements
Constructors
constructor
-
new RootMotionClip(
animationGroup: AnimationGroup,
options?: IRootMotionClipOptions,
): RootMotionClipAnalyzes an animation group and builds the in-place animation group to play instead of it.
Parameters
- animationGroup: AnimationGroup
defines the animation group to extract the root motion of; it is not changed
- options: IRootMotionClipOptions = {}
defines how the root motion is extracted
Returns RootMotionClip
- animationGroup: AnimationGroup
Accessors
animation Group
-
get animationGroup(): AnimationGroup
The in-place animation group to play: a clone of the source with the root motion left out of the root's keys. Animations the extraction does not rewrite are shared with the source unless the clip was created with IRootMotionClipOptions.cloneAnimations. It belongs to the scene, and is disposed with the clip.
Returns AnimationGroup
average Speed
-
get averageSpeed(): number
The speed the clip implies at a speed ratio of 1, in character space units per second.
Returns number
character Height
-
get characterHeight(): number
The vertical extent of the animated hierarchy at the first frame, in character space units. Thresholds are relative to it.
Returns number
character Node
-
The node the motion is measured in the local space of, and that a controller moves.
Returns TransformNode
contact Nodes
-
The contact nodes used to deduce the travel. Empty unless the source is RootMotionSource.FootContact.
Returns readonly TransformNode[]
controller
-
The controller the clip was added to, if any.
Returns Nullable<RootMotionController>
cycle Distance
-
get cycleDistance(): number
The distance covered by one cycle of the clip along the direction of travel, in character space units.
Returns number
cycle Offset
-
The travel covered by one cycle of the clip, in character space.
Returns Vector3
cycle Rotation
-
get cycleRotation(): number
The turn covered by one cycle of the clip about the up axis, in radians. Zero unless rotation is extracted.
Returns number
duration
-
get duration(): number
The length of one cycle of the clip in seconds, at a speed ratio of 1.
Returns number
extracts Rotation
-
get extractsRotation(): boolean
Whether the root's turning is extracted and applied to the character.
Returns boolean
from Frame
-
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
root Node
-
The root node the clip was analyzed with, or null when the group animates no position. It carries the motion only when RootMotionClip.source is RootMotionSource.Root.
Returns Nullable<TransformNode>
source
-
Where the travel comes from. RootMotionSource.None when no motion was found.
Returns RootMotionSource
source Animation Group
-
get sourceAnimationGroup(): AnimationGroup
The animation group the clip was analyzed from. It is never changed.
Returns AnimationGroup
to Frame
-
get toFrame(): number
The last frame of the range the clip is analyzed over.
Returns number
travel Direction
-
The direction the clip travels in over a cycle, in character space (unit length).
Returns Vector3
up Axis
-
The up axis in character space (unit length).
Returns Vector3
Methods
dispose
-
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
get Offset At Frame
get Rotation At Frame
-
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
- frame: number
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:
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.
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.