---
title: SampleExtractingRootMotion(ref AnimationStream, in TimerState)
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/clipsampler/sampleextractingrootmotion
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/clipsampler/sampleextractingrootmotion.md
last_updated: 2026-11-30
generated_at: 2026-11-30T21:07:41.722Z
locale: en-us
---

# SampleExtractingRootMotion(ref AnimationStream, in TimerState)

> Samples the clip with a clip timer, and removes the root motion from the pose, as an Animator does when it applies root motion.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Animations](/engine/7000.0/script-reference/unity/animations.md)
* **Assembly:** [UnityEngine.AnimationCoreModule](/engine/7000.0/script-reference/modules/unityengine-animationcoremodule.md)

## SampleExtractingRootMotion(AnimationStream, TimerState)

```csharp
public void SampleExtractingRootMotion(ref AnimationStream stream, in TimerState timer)
```

### Parameters

**** (\[AnimationStream]\(/engine/7000.0/script-reference/unity/animations/animationstream)): The stream to write the sampled channels to. It must have the rig that the sampler was created for.**** (\[TimerState]\(/engine/7000.0/script-reference/unity/animations/timerstate)): The clip timer to sample, from [Clip.ToTimerState](/engine/7000.0/script-reference/unity/animations/clip/totimerstate.md).

### Remarks

Use this method instead of [ClipSampler.Sample](/engine/7000.0/script-reference/unity/animations/clipsampler/sample.md) when you move the character with the root motion of the clip from [ClipSampler.SampleRootMotion](/engine/7000.0/script-reference/unity/animations/clipsampler/samplerootmotion.md). Otherwise the pose and the root motion both move the character.

The method samples the clip as `Sample` does, then expresses the root motion bone of the rig relative to the root transform of the clip at the time of the timer, as [AnimationStream.ExtractRootMotionBone](/engine/7000.0/script-reference/unity/animations/animationstream/extractrootmotionbone.md) does with [MotionOutput.RootTransform](/engine/7000.0/script-reference/unity/animations/motionoutput/roottransform.md). When the clip has **Loop Time** and **Loop Pose** enabled, the method removes the root motion before it corrects the pose, so the correction doesn't move the root motion bone back.

The channels of the root motion bone that the clip doesn't animate take their default value in the rig, unlike with `Sample`, because the previous call replaced all the channels of that bone.

The method only changes the root motion bone when the clip animates the translation or rotation of that bone or of one of its parent bones. Otherwise, the pose doesn't move with the root motion, for example when only the `RootT` and `RootQ` curves of the clip give the root motion, and the method samples the clip as `Sample` does. By default, the root motion bone is the root bone of the rig. To choose another bone, set [RigBuilder.RootMotionBoneId](/engine/7000.0/script-reference/unity/animations/rigbuilder/rootmotionboneid.md) when you build the rig.
