# MotionHandle

Control a scheduled tween's time, playback speed and lifetime. Seek a sequence through its parent handle once it owns the child.

Namespace: MeatMotion

Assembly: MeatMotion

```csharp
public struct MotionHandle : IEquatable<MotionHandle>
```

[Runtime/MotionHandle.cs · L5](../../../source/Runtime/MotionHandle.cs.html#L5)

## Seek and stop at the current value

Use `using MeatMotion;`. Seeking to 0.75 s writes 6. After cancellation, advancing the world leaves the value at 6.

```csharp
float value = 0f;
using var world = new MotionWorld();
var handle = MMotion.Create(0f, 8f, 1f)
    .WithScheduler(world)
    .Bind(v => value = v);
handle.Time = 0.75;
handle.Cancel();
world.Tick(0.1);
```

## StorageId

Identifies the storage containing the referenced slot.

```csharp
public int StorageId;
```

[Runtime/MotionHandle.cs · L7](../../../source/Runtime/MotionHandle.cs.html#L7)

## Index

Slot index inside a storage. Handle identity also includes StorageId and Version.

```csharp
public int Index;
```

[Runtime/MotionHandle.cs · L7](../../../source/Runtime/MotionHandle.cs.html#L7)

## Version

Generation number used to distinguish reuse of the same slot.

```csharp
public int Version;
```

[Runtime/MotionHandle.cs · L7](../../../source/Runtime/MotionHandle.cs.html#L7)

## None

Default handle that refers to no tween.

```csharp
public static readonly MotionHandle None;
```

[Runtime/MotionHandle.cs · L16](../../../source/Runtime/MotionHandle.cs.html#L16)

## ToString

Return the string representation.

```csharp
public override readonly string ToString()
```

Return value

- Returns: `string`

[Runtime/MotionHandle.cs · L17](../../../source/Runtime/MotionHandle.cs.html#L17)

## Equals

Compare for value equality.

```csharp
public readonly bool Equals(MotionHandle other)
```

Parameters and return value

- `other` (`MotionHandle`) Operand for the equality comparison.
- Returns: `bool`

[Runtime/MotionHandle.cs · L18](../../../source/Runtime/MotionHandle.cs.html#L18)

```csharp
public override readonly bool Equals(object obj)
```

Parameters and return value

- `obj` (`object`) Operand for the equality comparison.
- Returns: `bool`

[Runtime/MotionHandle.cs · L19](../../../source/Runtime/MotionHandle.cs.html#L19)

## GetHashCode

Return the hash code used with value equality.

```csharp
public override readonly int GetHashCode()
```

Return value

- Returns: `int`

[Runtime/MotionHandle.cs · L20](../../../source/Runtime/MotionHandle.cs.html#L20)

## operator ==

Test whether the handles identify the same motion.

```csharp
public static bool operator ==(MotionHandle a, MotionHandle b)
```

Parameters and return value

- `a` (`MotionHandle`) Operand for the equality comparison.
- `b` (`MotionHandle`) Operand for the equality comparison.
- Returns: `bool`

[Runtime/MotionHandle.cs · L21](../../../source/Runtime/MotionHandle.cs.html#L21)

## operator !=

Test whether the handles identify different motions.

```csharp
public static bool operator !=(MotionHandle a, MotionHandle b)
```

Parameters and return value

- `a` (`MotionHandle`) Operand for the equality comparison.
- `b` (`MotionHandle`) Operand for the equality comparison.
- Returns: `bool`

[Runtime/MotionHandle.cs · L22](../../../source/Runtime/MotionHandle.cs.html#L22)

## IsActive

Check whether the motion is active. A preserved motion can remain active at its endpoint.

```csharp
public readonly bool IsActive()
```

Return value

- Returns: `bool`

[Runtime/MotionHandle.cs · L23](../../../source/Runtime/MotionHandle.cs.html#L23)

## IsPlaying

Return true for an active motion that has not ended. A playback speed of zero alone does not make this false.

```csharp
public readonly bool IsPlaying()
```

Return value

- Returns: `bool`

[Runtime/MotionHandle.cs · L24](../../../source/Runtime/MotionHandle.cs.html#L24)

## TotalDuration

Total timeline length in seconds including delays and loops. Infinite looping yields positive infinity.

```csharp
public readonly double TotalDuration { get; }
```

[Runtime/MotionHandle.cs · L39](../../../source/Runtime/MotionHandle.cs.html#L39)

## Duration

Read the configured interpolation duration in seconds.

```csharp
public readonly float Duration { get; }
```

[Runtime/MotionHandle.cs · L40](../../../source/Runtime/MotionHandle.cs.html#L40)

## Delay

Read the delay in seconds configured on the builder.

```csharp
public readonly float Delay { get; }
```

[Runtime/MotionHandle.cs · L44](../../../source/Runtime/MotionHandle.cs.html#L44)

## Loops

Read the configured loop count.

```csharp
public readonly int Loops { get; }
```

[Runtime/MotionHandle.cs · L45](../../../source/Runtime/MotionHandle.cs.html#L45)

## CompletedLoops

Read the number of completed loops from a root handle.

```csharp
public readonly int CompletedLoops { get; }
```

[Runtime/MotionHandle.cs · L46](../../../source/Runtime/MotionHandle.cs.html#L46)

## PlaybackSpeed

One is normal speed, zero holds time, and negative values reverse direction. NaN and infinity are rejected.

```csharp
public float PlaybackSpeed { get; set; }
```

[Runtime/MotionHandle.cs · L47](../../../source/Runtime/MotionHandle.cs.html#L47)

## Preserve

Retain a root motion so the handle can seek it again after it completes.

```csharp
public MotionHandle Preserve()
```

Return value

- Returns: `MotionHandle`

[Runtime/MotionHandle.cs · L59](../../../source/Runtime/MotionHandle.cs.html#L59)

## Time

Read elapsed seconds, or write a finite time to seek a root motion and apply its value there.

```csharp
public double Time { get; set; }
```

[Runtime/MotionHandle.cs · L66](../../../source/Runtime/MotionHandle.cs.html#L66)

## Complete

Seek a finite root motion to its end and complete it. Infinite motions and sequence-owned children cannot be completed directly.

```csharp
public void Complete()
```

[Runtime/MotionHandle.cs · L77](../../../source/Runtime/MotionHandle.cs.html#L77)

## Cancel

Stop a root motion at its current value and notify cancellation.

```csharp
public void Cancel()
```

[Runtime/MotionHandle.cs · L85](../../../source/Runtime/MotionHandle.cs.html#L85)

## TryComplete

Complete a playing, finite root and report whether the request succeeded.

```csharp
public bool TryComplete()
```

Return value

- Returns: `bool`

[Runtime/MotionHandle.cs · L86](../../../source/Runtime/MotionHandle.cs.html#L86)

## TryCancel

Cancel an active root and return true. Invalid handles and sequence-owned children return false.

```csharp
public bool TryCancel()
```

Return value

- Returns: `bool`

[Runtime/MotionHandle.cs · L92](../../../source/Runtime/MotionHandle.cs.html#L92)

## Related types

- [CompositeMotionHandle](../../../en/api/compositemotionhandle/index.md)

- [MotionHandleExtensions](../../../en/api/motionhandleextensions/index.md)

- [MotionSequenceBuilder](../../../en/api/motionsequencebuilder/index.md)

- [R3MotionExtensions](../../../en/api/r3motionextensions/index.md)

- [UniTaskMotionExtensions](../../../en/api/unitaskmotionextensions/index.md)
