Hello, I want my code to get finished and I have come this far yet:
void Awake()
{
EnemyObject = GameObject.FindWithTag("Enemy");
}
void Update()
{
//attacking codes to kill "EnemyObject" (an Object with Tag called "Enemy")
//Tagged"Enemy" has been destroyed but now I can't find new target because my Awake function is just called when the game starts
EnemyObject = FindNewEnemy(); //lets try to find a new Object with an "Enemy"Tag
}
void FindNewEnemy() //this code is not working yet, so you cannot find a new Object with an "Enemy"Tag
{
GameObject[] newEnemy = GameObject.FindGameObjectsWithTag("Enemy")
foreach enemy in newEnemy
{
//a little code... //focus this GameObject as a new FindWithTag("Enemy")
break or return; //?
//Finnaly EnemyObject = GameObject.FindWithTag("Enemy"); every frame.
}
I got told I could do any List and set a boolean on the enemy when it is spawned?
Actually when my Monster is attacking a tagged object and kills it, is will not re-target the next object. so I am trying to fix my FindNewEnemy() function...but I am not coming further... =/
↧