# nextPosition

> Gets or sets the simulation position of the navmesh agent.

## Definition

* **Type:** Property
* **Namespace:** [UnityEngine.AI](/engine/6000.5/script-reference/unityengine/ai.md)
* **Assembly:** UnityEngine.AIModule

```csharp
public Vector3 nextPosition { get; set; }
```

### Remarks

The position vector is in world space coordinates and units.

The nextPosition is coupled to [\_position](/engine/6000.5/script-reference/unityengine/transform/position.md). In the default case the navmesh agent's Transform position will match the internal simulation position at the time the script Update function is called. This coupling can be turned on and off by setting [\_updatePosition](/engine/6000.5/script-reference/unityengine/ai/navmeshagent/updateposition.md).

When [\_updatePosition](/engine/6000.5/script-reference/unityengine/ai/navmeshagent/updateposition.md) is true, the [\_position](/engine/6000.5/script-reference/unityengine/transform/position.md) reflects the simulated position, when false the position of the transform and the navmesh agent is not synchronized, and you'll see a difference between the two in general. When [\_updatePosition](/engine/6000.5/script-reference/unityengine/ai/navmeshagent/updateposition.md) is turned back on, the [\_position](/engine/6000.5/script-reference/unityengine/transform/position.md) will be immediately move to match nextPosition.

By setting nextPosition you can directly control where the internal agent position should be. The agent will be moved towards the position, but is constrained by the navmesh connectivity and boundaries. As such it will be useful only if the positions are continuously updated and assessed.

Additionally it can be useful to control the agent position directly - especially if the gameobject transform is controlled by something else - e.g. animator, physics, scripted or input.

Additional Resources: [NavMeshAgent.Warp](/engine/6000.5/script-reference/unityengine/ai/navmeshagent/warp.md), [NavMeshAgent.Move](/engine/6000.5/script-reference/unityengine/ai/navmeshagent/move.md)

### Examples

```csharp
using UnityEngine;
using UnityEngine.AI;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        // Update the transform position explicitly in the OnAnimatorMove callback
        GetComponent<NavMeshAgent>().updatePosition = false;
    }

    void OnAnimatorMove()
    {
        transform.position = GetComponent<NavMeshAgent>().nextPosition;
    }
}
```

```csharp
using UnityEngine;
using UnityEngine.AI;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    public bool agentIsControlledByOther;
    void Update()
    {
        var agent = GetComponent<NavMeshAgent>();
        agent.updatePosition = !agentIsControlledByOther;
        if (agentIsControlledByOther)
        {
            GetComponent<NavMeshAgent>().nextPosition = transform.position;
        }
    }
}
```
