using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; public class Enemy : MonoBehaviour { public NavMeshAgent _agent; public int bloodvolume; public Transform player; // Start is called before the first frame update void Start() { _agent = GetComponent(); player=GameObject.FindWithTag("Player").transform; } // Update is called once per frame void Update() { setMoveTo(player); if (bloodvolume <= 0) { //ToDo Destroy(this.gameObject); } } public void EnemyHpDown(int hp) { bloodvolume -= hp; } public void setMoveTo(Transform target) { _agent.SetDestination(target.position); } }