Documentation

Unity Engine

Download Unity

Unity Engine

ExtractRootMotionBone(float3, quaternion)

Removes the root motion from the pose by expressing the root motion bone relative to a root transform.
Read time 1 minuteLast updated 4 hours ago

Definition

public void ExtractRootMotionBone(float3 rootPosition, quaternion rootRotation)

Parameters

rootPosition

The position of the root transform in character space.

rootRotation

The rotation of the root transform in character space.

Remarks

To sample a clip without its root motion, use ClipSampler.SampleExtractingRootMotion, which calls this method for you. Use this method for a pose that you build yourself, for example after you change the pose of a clip: pass MotionOutput.RootTransform from ClipSampler.SampleRootMotion at the same time. Without this call, the pose still moves with the curves of the clip, so the character moves twice.
Call it only when the clip animates the translation or rotation of the root motion bone or of one of its parent bones. Otherwise the pose doesn't move with the root motion, and this method moves the pose against it. This method doesn't handle Loop Pose: for a clip with Loop Time and Loop Pose enabled, the pose was already corrected, so the result differs from
SampleExtractingRootMotion
.
The method changes the local to parent channels of the bone at RigDefinition.RootMotionBoneIndex so that its new transform in character space is its current transform in character space, relative to the root transform. The parents of the bone keep their values. The method does nothing if the rig has no skeleton.
When a parent of the bone has a non-uniform scale, the result is an approximation, as with AnimationStream.SetLocalToCharacterTRS.