Please do not create unnecessary voting.
Please use code tags. https://discussions.unity.com/t/481379
Please describe what do you mean “limit” exactly and what did you try so far?
private bool spawnReady;
public int actualEntitys;
public int maxEntitys;
void Update()
{
spawnEntitys()
}
private void spawnEntitys()
{
for (int i = actualEntitys; i <= maxEntitys; i++)
{
actualEntitys++;
Instantiate(spawnee, transform.position, transform.rotation);
}
}
or:
private bool spawnReady;
public int actualEntitys;
public int maxEntitys;
void Update()
{
if(actualEntitys < maxEntitys)
{
actualEntitys++;
Instantiate(spawnee, transform.position, transform.rotation);
}
}
or in a while loop:
private bool spawnReady;
public int actualEntitys;
public int maxEntitys;
void Update()
{
while(actualEntitys < maxEntitys)
{
actualEntitys++;
Instantiate(spawnee, transform.position, transform.rotation);
}
}
I think Terraya’s middle example does what you want, what’s the problem with that? : - )
Just put it in a new script , put that script onto Gameobject in hiearchy and fill in the public variables in inspector.(what to spawn , and how much is max (10 in your example))
although im not sure whats with the spawnReady bool in his example,… it doesnt do anything + its private so… just sayin . - )
How does it not work? Try this again. and remember that what you put this script on, in that place will all be spawned, and they will probably be all in the same position so its like there is only one of them.
public class TimedSpawn : MonoBehaviour
{
public GameObject spawnee;
public int actualEntitys;
public int maxEntitys;
void Update()
{
while(actualEntitys < maxEntitys)
{
actualEntitys++;
Instantiate(spawnee, transform.position, transform.rotation);
}
}
}