using System.Collections.Generic;
using UnityEngine;
public class monster04 : MonoBehaviour {
//導航系統
NavMeshAgent MonsterAI;
//宣告玩家物件
public GameObject Player;
// Use this for initialization
void Start () {
//導航元件MonsterAI = 自身物件中的NavMeshAgent屬性
MonsterAI = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update ()
{
if (Player == null) {
//尋找場景中Tag標籤為Player的物件
Player = GameObject.FindWithTag ("Player");
} else {
//導航至Player物件的座標
MonsterAI.destination = Player.transform.position;
}
}
}