using UnityEngine; using System.Collections; using UnityEngine.AI; public class demo : MonoBehaviour { private NavMeshAgent agent; void Start() { agent = GetComponent(); } void Update() { RaycastHit hit; if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) agent.SetDestination(hit.point); } } }