# TriggerSpawn

{% stepper %}
{% step %}

### Create a script

```csharp
using UnityEngine;
using UnityEngine.InputSystem;
using MeshAnimation;

public class MeshAnimationInteractExample : MonoBehaviour
{
    [Tooltip("Target object with MeshAnimationInteract component.")]
    public MeshAnimationInteract target;

    [Header("Spawn Example")]
    [Tooltip("Animation to play on spawn. Must match the name in MeshAnimation.")]
    public string spawnAnimation = "";

    private void Update()
    {
        var keyboard = Keyboard.current;

        // Example: trigger spawn animation on Space
        if (keyboard != null && keyboard.spaceKey.wasPressedThisFrame)
        {
            target.spawn.animation = spawnAnimation;
            target.TriggerSpawn();
        }
    }
}
```

{% endstep %}

{% step %}

### Select the animations you want

<figure><img src="/files/UUCGiqTopAcT3YXZUyeb" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Done

Now when you jump, the animation will play!
{% endstep %}
{% endstepper %}


---

# 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/triggerspawn.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.
