寻路功能:
public class MOVE : MonoBehaviour {
//玩家
public GameObject player;
//敌人
public GameObject go;
void Start () {
go = GameObject.Find("Cube");
player = this.gameObject;
//查找标签为Player的物体并返回
player = GameObject.FindGameObjectWithTag("Player");
}
void Update () {
//敌人面向玩家
go.transform.LookAt(player.transform);
//敌人向玩家方向移动
go.transform.Translate(go.transform.forward *-1f* Time.deltaTime * 5f);
}
}