> For the complete documentation index, see [llms.txt](https://oscar-gracian.gitbook.io/easy-character-movement-2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://oscar-gracian.gitbook.io/easy-character-movement-2/walkthrough/ai-navigation.md).

# AI Navigation

In this example, we make use of the new `NavMeshCharacter` component introduced in version 1.4.0 to implement a typical click-to-move movement.

```csharp
public class ClickToMove : MonoBehaviour
{
    public Camera mainCamera;
    public Character character;

    public LayerMask groundMask;

    private NavMeshCharacter _navMeshCharacter;

    private void Awake()
    {
        _navMeshCharacter = character.GetComponent<NavMeshCharacter>();
    }

    private void Update()
    {
        if (Input.GetMouseButton(0))
        {
            Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out RaycastHit hitResult, Mathf.Infinity, groundMask))
                _navMeshCharacter.MoveToDestination(hitResult.point);
        }
    }
}
```

This utilizes the `NavMeshCharacter` to instruct the character to move to the world position where the player clicked. Internally, this uses a `NavMeshAgent` to intelligently traverse the world.
