# MoveLocation(NavLocation, Vector3, int)

> Translates a NavMesh location to another position without losing contact with the surface.

## Definition

* **Type:** Method
* **Namespace:** [Unity.AI.Navigation.LowLevel](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel.md)
* **Assembly:** UnityEngine.AIModule

```csharp
public readonly NavLocation MoveLocation(NavLocation location, Vector3 destination, int areaMask = -1)
```

### Parameters

**** (\[NavLocation]\(/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navlocation)): The position to move across the NavMesh surface.**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): The world position to move the location toward.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A bitmask with a value of 1 at the indexes of the areas that can be traversed, and a value of 0 for areas that aren't traversable. The default value is [NavMesh.AllAreas](/engine/6000.5/script-reference/unityengine/ai/navmesh/allareas.md).

### Returns

| Type                                                                                       | Description                                                                                          |
| ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
| [NavLocation](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navlocation.md) | A new location on the NavMesh placed as closely as possible to the specified `destination` position. |

### Remarks

This method returns the location on the NavMesh that is closest to the `destination` position and that also has a continuous connection on the NavMesh surface, through the allowed area types, all the way to the start position specified by the `location` parameter. If the `destination` position is outside the edges of the surface or of its allowed areas, this method returns a position at the edge. The search for a connected pathway is constrained to a circular area between the start and destination points. This constraint makes the operation fast, but it doesn't find a path that deviates widely to go around large obstacles.

The movement doesn't cross NavMesh Links.

You can safely call this operation while a separate pathfinding query is in progress on the same query buffer instance.

For more information about the area types that `areaMask` filters, refer to Areas and Costs.

Additional Resources: [NavWorld.MoveLocations](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/movelocations.md)

### Examples

```csharp
using UnityEngine;
using UnityEngine.AI;
using Unity.AI.Navigation.LowLevel;

public class MoveLocationExample : MonoBehaviour
{
    public Transform target;

    void Update()
    {
        using NavWorld world = NavWorld.GetDefaultWorld();
        NavLocation start = world.MapLocation(transform.position, Vector3.one, 0);
        if (!world.IsValid(start))
            return;

        NavLocation moved = world.MoveLocation(start, target.position, NavMesh.AllAreas);
        Debug.DrawLine(start.position, moved.position, Color.cyan);
    }
}
```
