# API

### MeshAnimationInteract

A single interaction component that drives `MeshAnimation` from user and physics events. Add one per GameObject. Enable only the sections you need - disabled sections have zero runtime cost.

**Requires:** `MeshAnimation` on the same (or referenced) GameObject, a `Collider` for pointer/physics triggers.

***

#### Inspector Fields

| Field           | Type          | Description                                                         |
| --------------- | ------------- | ------------------------------------------------------------------- |
| `meshAnimation` | MeshAnimation | Target component. Leave empty to auto-resolve from this GameObject. |

***

#### Triggers

**Hover**

Fires when the cursor enters or exits the object's collider.

| Field            | Type       | Description                                         |
| ---------------- | ---------- | --------------------------------------------------- |
| `enabled`        | bool       | Enable this trigger.                                |
| `enterAnimation` | string     | Animation played on cursor enter.                   |
| `exitAnimation`  | string     | Animation played on cursor exit. Empty = `StopAll`. |
| `useCursorPivot` | bool       | Use the cursor hit point as the effect pivot.       |
| `onEnter`        | UnityEvent | Fired on enter.                                     |
| `onExit`         | UnityEvent | Fired on exit.                                      |

***

**Hold**

Fires on mouse press and release, with optional activation delay.

| Field                | Type       | Description                                                                      |
| -------------------- | ---------- | -------------------------------------------------------------------------------- |
| `enabled`            | bool       | Enable this trigger.                                                             |
| `mouseButton`        | int (0–2)  | Mouse button: 0 = Left, 1 = Right, 2 = Middle.                                   |
| `activationDelay`    | float      | Seconds to hold before the animation fires.                                      |
| `minHoldTime`        | float      | Minimum hold duration. Release before this silently cancels with no `onRelease`. |
| `holdAnimation`      | string     | Animation played while held. Suggested: Ambient (loops = -1), Directional.       |
| `releaseAnimation`   | string     | Animation played on release. Empty = `StopAll`.                                  |
| `usePressPointPivot` | bool       | Use the press point as the effect pivot.                                         |
| `onHoldStart`        | UnityEvent | Fired when hold activates.                                                       |
| `onRelease`          | UnityEvent | Fired on release.                                                                |

***

**Proximity**

Fires when nearby colliders enter or leave a radius around this object.

| Field             | Type       | Description                                  |
| ----------------- | ---------- | -------------------------------------------- |
| `enabled`         | bool       | Enable this trigger.                         |
| `triggerLayers`   | LayerMask  | Layers that can activate proximity.          |
| `triggerDistance` | float      | Enter range (units).                         |
| `exitDistance`    | float      | Exit range. Must be ≥ `triggerDistance`.     |
| `enterAnimation`  | string     | Animation played on enter.                   |
| `exitAnimation`   | string     | Animation played on exit. Empty = `StopAll`. |
| `onEnter`         | UnityEvent | Fired on enter.                              |
| `onExit`          | UnityEvent | Fired on exit.                               |

***

**Impact**

Fires on mouse click or physics collision, using the contact point as the effect pivot.

| Field               | Type              | Description                                                                                 |
| ------------------- | ----------------- | ------------------------------------------------------------------------------------------- |
| `enabled`           | bool              | Enable this trigger.                                                                        |
| `useClick`          | bool              | Fire on mouse click.                                                                        |
| `mouseButton`       | int (0–2)         | Mouse button for click.                                                                     |
| `animation`         | string            | Default animation. Suggested: JellyTap, HitSquash, DentImpact, ShockwaveRing.               |
| `useCollision`      | bool              | Fire on `OnCollisionEnter` / `OnTriggerEnter`.                                              |
| `collisionLayers`   | CollisionLayer\[] | Per-layer collision entries. Empty `animation` falls back to the default `animation` field. |
| `minImpulse`        | float             | Minimum collision impulse. Filters grazing contacts.                                        |
| `cooldown`          | float             | Minimum seconds between impacts.                                                            |
| `useAnimationPivot` | bool              | Use the pivot defined inside the animation instead of the contact point.                    |
| `onImpact`          | UnityEvent        | Fired on each impact.                                                                       |

**CollisionLayer fields:**

| Field       | Type      | Description                                                        |
| ----------- | --------- | ------------------------------------------------------------------ |
| `layers`    | LayerMask | Layers that activate this entry.                                   |
| `animation` | string    | Animation to play. Empty = falls back to `ImpactConfig.animation`. |

***

**Scroll**

Scrubs an animation with the mouse scroll wheel.

| Field          | Type   | Description                                        |
| -------------- | ------ | -------------------------------------------------- |
| `enabled`      | bool   | Enable this trigger.                               |
| `animation`    | string | Animation to scrub. Suggested: Twist, StretchPull. |
| `sensitivity`  | float  | Scroll units per second mapped to progress 0→1.    |
| `clamp`        | bool   | Clamp accumulated scroll to \[0, 1].               |
| `resetOnIdle`  | bool   | Smoothly reset to 0 when scrolling stops.          |
| `resetSpeed`   | float  | Reset speed in progress units per second.          |
| `invertScroll` | bool   | Reverse scroll direction.                          |

***

**Spawn**

Fires an animation automatically on `Start`, `OnEnable`, or both.

| Field       | Type       | Description                                   |
| ----------- | ---------- | --------------------------------------------- |
| `enabled`   | bool       | Enable this trigger.                          |
| `triggerOn` | TriggerOn  | When to fire: `Start`, `OnEnable`, or `Both`. |
| `animation` | string     | Animation to play. Suggested: BuildingEmerge. |
| `delay`     | float      | Delay in seconds before playing.              |
| `onSpawn`   | UnityEvent | Fired on spawn.                               |

***

#### Public API

**Methods**

| Method                                                         | Description                                                                                                                                 |
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `ForceHoverEnter()`                                            | Manually trigger hover enter state and fire its animation.                                                                                  |
| `ForceHoverExit()`                                             | Manually trigger hover exit state and fire its animation.                                                                                   |
| `ForceHoldStart()`                                             | Manually activate hold state and fire its animation.                                                                                        |
| `ForceRelease()`                                               | Manually release hold state and fire its animation.                                                                                         |
| `ForceProximityEnter()`                                        | Manually trigger proximity enter and fire its animation.                                                                                    |
| `ForceProximityExit()`                                         | Manually trigger proximity exit and fire its animation.                                                                                     |
| `SetScrollValue(float value)`                                  | Set scroll progress directly (0–1). Drives animation via `Evaluate()`.                                                                      |
| `TriggerSpawn()`                                               | Manually fire the spawn animation (respects `delay`).                                                                                       |
| `ForceImpactAt(Vector3 worldPoint, string animationName = "")` | Fire an impact animation at a world-space point from external code. Empty `animationName` falls back to the animation set in Impact Config. |

**Properties (read-only)**

| Property      | Type  | Description                                      |
| ------------- | ----- | ------------------------------------------------ |
| `IsHovered`   | bool  | True if cursor is currently over this object.    |
| `IsHolding`   | bool  | True if hold is currently active.                |
| `IsInRange`   | bool  | True if a proximity trigger is currently active. |
| `ScrollValue` | float | Current accumulated scroll progress (0–1).       |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tkkoi-developer.gitbook.io/tkkoiassets/mesh-animation/start/interaction/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
