# Hand Animator

## Hand Animator

The `HandAnimator` class is responsible for managing the animation and pose transitions of a hand in Unity. It uses the `HandPoseData` struct to represent various hand poses and smoothly transitions between them based on user inputs or interactions with `HandPoseArea` components.

<figure><img src="https://2959669391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5zKO0EvOjzUDeT2aiFk3%2Fuploads%2FuDgoET9kQkwbiugeiajk%2Fimage.png?alt=media&#x26;token=565f85a5-4811-4225-b535-b7db0df6b459" alt=""><figcaption></figcaption></figure>

### Public Variables

* `Default Pose Transition Time` : The default time it takes to transition between poses.
* `Default Pose Transition Curve` : The default animation curve used for transitioning between poses.
* `Current Pose Area` : The current [`HandPoseArea` ](https://earnest-robot.gitbook.io/auto-hand-docs/custom-poses#hand-pose-areas)the hand is interacting with.

### Properties

* `Hand Pose Data Non Alloc` : Returns a reference to the non-allocated [`HandPoseData`](https://earnest-robot.gitbook.io/auto-hand-docs/auto-hand/custom-poses/hand-pose-data) used for temporary calculations.
* `Open Hand Pose` : Returns a reference to the `HandPoseData` representing the open hand pose.
* `Close Hand Pose` : Returns a reference to the `HandPoseData` representing the closed hand pose.
* `Current Input Pose` : Returns a reference to the `HandPoseData` representing the current input pose.
* `Current Target Pose` : Returns a reference to the `HandPoseData` representing the target pose the hand is transitioning to.
* `Current Hand Pose` : Returns a reference to the `HandPoseData` representing the current hand pose.
* `Current Hand Smooth Pose` : Returns a reference to the `HandPoseData` representing the smoothly interpolated hand pose.

### Public Methods

#### SetTargetPose()

```csharp
csharpCopy codepublic virtual void SetTargetPose(ref HandPoseData poseData, float transitionTime, AnimationCurve animationCurve)
```

Sets the target pose for the hand to transition to over a specified duration with a specified animation curve.

**Parameters:**

* `poseData`: The target pose data.
* `transitionTime`: The time it takes to transition to the target pose.
* `animationCurve`: The animation curve to use for the transition.

#### SetPose()

```csharp
csharpCopy codepublic void SetPose(ref HandPoseData pose, float transitionTime, AnimationCurve animationCurve)
public void SetPose(ref HandPoseData pose, float transitionTime)
public void SetPose(ref HandPoseData pose)
```

Sets the target pose for the hand with various overloads for specifying the transition time and animation curve.

**Parameters:**

* `pose`: The target pose data.
* `transitionTime`: (Optional) The time it takes to transition to the target pose. Default is `defaultPoseTransitionTime`.
* `animationCurve`: (Optional) The animation curve to use for the transition. Default is `defaultPoseTransitionCurve`.

#### GetCurrentHandPose()

```csharp
csharpCopy codepublic ref HandPoseData GetCurrentHandPose()
```

Returns a reference to the current hand pose data, ignoring any objects being held.

**Returns:**

* `HandPoseData`: A reference to the current hand pose data.

#### CopyHandData()

```csharp
csharpCopy codepublic void CopyHandData(ref HandPoseData handPose)
```

Copies the current hand pose data to the specified `HandPoseData` object, ignoring any objects being held.

**Parameters:**

* `handPose`: The `HandPoseData` object to copy the current hand pose data to.

#### CancelPose()

```csharp
csharpCopy codepublic void CancelPose(float cancelPoseTransitionTime)
public void CancelPose()
```

Cancels any ongoing pose transitions and returns the hand to its default state over a specified duration.

**Parameters:**

* `cancelPoseTransitionTime`: (Optional) The time it takes to cancel the current pose transition. Default is `defaultPoseTransitionTime`.

#### IsPosing()

```csharp
csharpCopy codepublic bool IsPosing()
```

Checks if the hand is currently locked into a pose.

**Returns:**

* `bool`: `True` if the hand is currently posing, otherwise `False`.

#### SetTargetPose()

```csharp
csharpCopy codepublic virtual void SetTargetPose(ref HandPoseData poseData, float transitionTime, AnimationCurve animationCurve)
```

Sets a new target pose for the hand to transition to, with specified transition time and animation curve.

**Parameters:**

* `poseData`: The pose data to transition to.
* `transitionTime`: The duration of the transition.
* `animationCurve`: The animation curve for the transition.

#### SetPose()

```csharp
csharpCopy codepublic void SetPose(ref HandPoseData pose, float transitionTime, AnimationCurve animationCurve)
public void SetPose(ref HandPoseData pose, float transitionTime)
public void SetPose(ref HandPoseData pose)
```

Sets a new pose for the hand with optional transition time and animation curve.

**Parameters:**

* `pose`: The pose data to set.
* `transitionTime`: The duration of the transition (optional).
* `animationCurve`: The animation curve for the transition (optional).

#### GetCurrentHandPose()

```csharp
csharpCopy codepublic ref HandPoseData GetCurrentHandPose()
```

Gets the current pose of the hand.

**Returns:**

* `HandPoseData`: A reference to the current hand pose data.

#### CopyHandData()

```csharp
csharpCopy codepublic void CopyHandData(ref HandPoseData handPose)
```

Copies the current hand pose data to the specified `HandPoseData` object.

**Parameters:**

* `handPose`: The pose data to copy the current hand pose to.

#### CancelPose()

```csharp
csharpCopy codepublic void CancelPose(float cancelPoseTransitionTime)
public void CancelPose()
```

Cancels the current pose transition and reverts to the default pose.

**Parameters:**

* `cancelPoseTransitionTime`: The time to transition back to the default pose (optional).

#### IsPosing()

```csharp
csharpCopy codepublic bool IsPosing()
```

Checks if the hand is currently in a pose transition or locked into a pose.

**Returns:**

* `bool`: `True` if the hand is posing, `False` otherwise.
