'How do I spawn repeatedly object whot 0.1 seconds between them?
I want to spawn a 100 object whit 0.1 seconds in between. I have this but they still spawn all at once.
private float timer = 0.0f;
bool goSpawn = false;
private void Update()
{
if (goSpawn)
{
timer += Time.deltaTime;
}
}
public void spawnAnimals()
{
goSpawn = true;
for (int i = 0; i < 100;)
{
if (timer > 2f)
{
RndSpawnPos = new Vector3(Random.Range(3.30f, 5.70f), 0.78f, Random.Range(-3.00f, 3.01f));
Instantiate(animal, RndSpawnPos, Quaternion.identity);
i++;
timer = 0.0f;
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
