- Home /
Im trying to update enemy list but my code is realy laggy
I have enemy and npc spawners and in the list it updates to check if any new enemy have spawned to send the information to the ai.
void Update()
{
GameObject[] enemyArray = GameObject.FindGameObjectsWithTag("Enemy");
Enemies = new List<GameObject>(enemyArray);
GameObject[] NPCArray = GameObject.FindGameObjectsWithTag("NPC");
NPCs = new List<GameObject>(NPCArray);
NPCs.Add(GameObject.FindGameObjectWithTag("Player"));
// Enemies = GameObject.FindGameObjectsWithTag("");
setNpcListLength = NPCs.Count;
if (Enemies.Count == 0)
{
Debug.Log("Player Has Won");
SceneManager.LoadScene(SceneNumber);
}
}
Comment
Your answer
Follow this Question
Related Questions
micro Jittering, stuttering... bug of unity? 2 Answers
Why is the editor navigation so choppy? 1 Answer
Unity running slowly 1 Answer
How to do the following 0 Answers