---
title: Sample
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/sample
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/clipsampler/sample.md
last_updated: 2026-11-30
generated_at: 2026-11-30T20:50:09.011Z
locale: en-us
---

# Sample

> Samples the clip at the time of a clip timer. The method computes the value of each curve of the clip at that time, and overwrites the matching channels of the animation stream.

## 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)

## Sample(AnimationStream, TimerState)

Samples the clip at the time of a clip timer. The method computes the value of each curve of the clip at that time, and overwrites the matching channels of the animation stream.

```csharp
public void Sample(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

The channels that the clip doesn't animate keep their value. To reset them to the rig defaults, call [AnimationStream.ResetToDefaultValues](/engine/7000.0/script-reference/unity/animations/animationstream/resettodefaultvalues.md) before you sample.

The method samples the clip curves at [TimerState.Time](/engine/7000.0/script-reference/unity/animations/timerstate/time.md). [Clip.ToTimerState](/engine/7000.0/script-reference/unity/animations/clip/totimerstate.md) adds the cycle offset when it creates the timer, so the timer time already includes the cycle offset. To sample at a playback time without a timer, use [ClipSampler.Sample](/engine/7000.0/script-reference/unity/animations/clipsampler/sample.md), which adds the cycle offset for you.

When the clip has **Loop Time** and **Loop Pose** enabled, the method also corrects the pose to close the gap between the first and last frames. The correction is zero at the start of [TimerState.Range](/engine/7000.0/script-reference/unity/animations/timerstate/range.md) and grows until the end of the range, where the pose matches the pose of the first frame.

The sampler interpolates between the frames of the clip, so it doesn't snap the time to a frame. To play a clip backward, set a negative [TimerState.TimeScale](/engine/7000.0/script-reference/unity/animations/timerstate/timescale.md) on the timer.

## Sample(AnimationStream, DiscreteTime)

Samples the clip at a playback time. The method computes the value of each curve of the clip at that time, and overwrites the matching channels of the animation stream.

```csharp
public void Sample(ref AnimationStream stream, DiscreteTime time)
```

### 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.**** (\[DiscreteTime]\(/engine/7000.0/script-reference/unity/integertime/discretetime)): The playback time in seconds from the start of the clip.

### Remarks

The channels that the clip doesn't animate keep their value. To reset them to the rig defaults, call [AnimationStream.ResetToDefaultValues](/engine/7000.0/script-reference/unity/animations/animationstream/resettodefaultvalues.md) before you sample.

This method already applies the [Clip.LoopTime](/engine/7000.0/script-reference/unity/animations/clip/looptime.md) setting and the cycle offset of the clip to the playback time you pass. Don't pass the [TimerState.Time](/engine/7000.0/script-reference/unity/animations/timerstate/time.md) of a clip timer, because the timer already applied the `LoopTime` setting and the cycle offset to that time. To sample with a clip timer, use [ClipSampler.Sample](/engine/7000.0/script-reference/unity/animations/clipsampler/sample.md). For how `LoopTime` and the cycle offset change the time, see [Clip.ToTimerState](/engine/7000.0/script-reference/unity/animations/clip/totimerstate.md).

The sampler interpolates between the frames of the clip, so it doesn't snap the time to a frame. To play a clip backward, pass a playback time that decreases between calls.
