void Update()
{
if (Input.GetMouseButtonDown(1))
{
Ray ray = Camera .main .ScreenPointToRay ( Input.mousePosition);
RaycastHit hit;
if (!Physics.Raycast(ray, out hit))
{
//hit.collider .gameObject //射线打到的物体
return;
}
navMeshAgent.destination = hit.point ;//碰撞点
}
}
![](https://Wei715547.github.io/post-images/1589025091557.jpg)
![](https://Wei715547.github.io/post-images/1589025123139.jpg)