---
tags:
    - "Navigation"
    - "NavMesh"
    - "AI"
    - "Agent"
    - "Teleport"
    - "Place"
    - "Move"
---

# Nav Mesh Agent Warp

[Navigation](../index.md) / [Nav Mesh Agent](index.md) / **Nav Mesh Agent Warp**

## Description

Teleports the Nav Mesh Agent to a position on the Nav Mesh and clears its path

## Parameters

| Name | Description |
| :--- | :---------- |
| Nav Mesh Agent | The Nav Mesh Agent component that is teleported |
| Position | The position to teleport to. It must be close enough to the Nav Mesh |

## Code

```cs
using System;
using UnityEngine;
using UnityEngine.AI;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("Nav Mesh Agent Warp")]
    [Category("Navigation/Nav Mesh Agent/Warp")]
    [Description("Teleports the Nav Mesh Agent to a position on the Nav Mesh and clears its path")]

    [Image(typeof(IconNavmeshAgent), ColorTheme.Type.Red)]
    [Keywords("Navigation", "NavMesh", "AI", "Agent", "Teleport", "Place", "Move")]

    [Parameter("Nav Mesh Agent", "The Nav Mesh Agent component that is teleported")]
    [Parameter("Position", "The position to teleport to. It must be close enough to the Nav Mesh")]

    [Serializable]
    public class InstructionNavMeshAgentWarp : Instruction
    {
        [SerializeField] private GetGameObject m_NavMeshAgent = new GetGameObject(
            new GenTypeGameObject_NavMeshAgent()
        );

        [SerializeField] private GetVector3 m_Position = new GetVector3();

        protected override string GetTitle(GameObject source)
        {
            string method = TextUtils.ThemeAsKeyword("Warp");
            return $"{this.m_NavMeshAgent} {method} ({this.m_Position})";
        }

        protected override Awaitable Run(Args args)
        {
            NavMeshAgent agent = this.m_NavMeshAgent.Get<NavMeshAgent>(args);
            if (agent == null) return Done;

            agent.Warp(this.m_Position.Get(args));
            return Done;
        }
    }
}
```

