NavMash

Скрипт для перемещения NavMashAgent в точку клика

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class PlayerController : MonoBehaviour
{

    private NavMeshAgent agent;
    public Camera camera;
    void Start()
    {
        agent = GetComponent<NavMeshAgent>();
    }

   
    void Update()
    {

        if (Input.GetMouseButtonDown(0))
        {
          
          RaycastHit hit;
            if (Physics.Raycast(camera.ScreenPointToRay(Input.mousePosition), out hit))
            {     
                agent.SetDestination(hit.point);
            }
           
        }    
    }
}