继续学习c#。。
简单的寻路,用的是U3D自带的算法,代码如下
using System.Collections;
public class Player : MonoBehaviour {
public NavMeshAgent agent;
Vector3 point;
Ray aray;
RaycastHit ahit;
public GameObject targetPoint;
void Start()
{
targetPoint.active=false;
}
void Update ()
{
if(Input.GetMouseButtonDown (0))
{
aray=Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(aray,out ahit))
{
point=ahit.point;
//Instantiate(targetPoint,point,transform.rotation);
targetPoint.active=true;
targetPoint.transform.position=point;
}
}
agent.SetDestination(point);
}
}
和之前的相机跟随一块的效果