# 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.


---

# 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://oscar-gracian.gitbook.io/easy-character-movement-2/walkthrough/ai-navigation.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.
