Unity之简单寻路功能
作者:
菜鸟程序猿 | 来源:发表于
2017-03-07 22:20 被阅读0次寻路功能:
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);
}
}
本文标题:Unity之简单寻路功能
本文链接:https://www.haomeiwen.com/subject/jlevgttx.html
网友评论