# ForceImpactAt

{% 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;

    [Tooltip("Animation name to play on impact. Leave empty to use the one set in Impact Config.")]
    public string animationName = "";

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

        // Example: fire impact at mouse click position via raycast
        if (mouse != null && mouse.rightButton.wasPressedThisFrame)
        {
            Ray ray = Camera.main.ScreenPointToRay(mouse.position.ReadValue());
            if (Physics.Raycast(ray, out RaycastHit hit))
                FireAt(hit.point);
        }

        // Example: fire impact at this object's position on Space
        if (keyboard != null && keyboard.spaceKey.wasPressedThisFrame)
            FireAt(transform.position);
    }

    private void FireAt(Vector3 worldPoint)
    {
        if (target == null) return;
        target.ForceImpactAt(worldPoint, animationName);
    }

    // Example: call from UnityEvent or another script directly
    public void FireAtCenter()
    {
        if (target == null) return;
        Bounds bounds = target.GetComponent<MeshFilter>().sharedMesh.bounds;
        Vector3 center = target.transform.TransformPoint(bounds.center);
        target.ForceImpactAt(center, animationName);
    }
}
```

{% endstep %}

{% step %}

### Add “Mesh Animation Interact” to the appropriate field. Also, enter the name of the animation you want to trigger.

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

{% step %}

### Done!

Now, when you move over to the object and right-click, it will play an animation!
{% 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/forceimpactat.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.
