NavMeshPointMovement.cs
using UnityEngine; using UnityEngine.AI; public class NavMeshPointMovement : MonoBehaviour { NavMeshAgent agent; RaycastHit hit; void Awake() { agent = GetComponent<NavMeshAgent>(); } void Update() { if (Input.GetMouseButtonDown(0)) { if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100, LayerMask.GetMask("Ground"))) { agent.SetDestination(hit.point); } } } }