Infinite instantiation w/ for loop? Please help!
for(int i = 0; i < enemiesInWave; i++)
{
Instantiate(zombieObject, ZombieSpawn().transform.position, ZombieSpawn().gameObject.transform.rotation);
print(i + " " + enemiesInWave);
}
why does it instantiate infinitely?
Comment
Answer by Matthewj866 · May 09, 2017 at 11:47 PM
Hi there.
Judging from that snippet I'm going to assume enemiesInWave
is modified by the amount of zombies you instantiate, because...well that's kind of the only thing it can be based on that snippet alone.
It might also be possible that the method this loop lives in is being called repeatedly, such as in Update()
as an example.
Hope this helps.
Your answer
Follow this Question
Related Questions
Spawn Prefab based on int value 1 Answer
Make a collision check when spawning with Instantiate 1 Answer
instantiate capacity 0 Answers
How to do a Spawn Animation 1 Answer