I have this line of code, and I would like to know if an object can be instantiated every second.
The thing would be that when entering a certain area the bullets are instantiated every X time
Instantiate(Bala, SpawnBala.position, SpawnBala.rotation);
Yes it can.
If you want a better answer, please be more specific in your question.
If you want something to repeat every second, there are several ways to do this:
One is InvokeRepeating:
Another is to use a coroutine:
Another way is to simply write your own code to count up to one second:
float timePast=0f;
float maxtime=1f;
void Update ()
{ timePast+=Time.deltaTime;
if (timePast>maxTime)
{ timePast=0;
// do something here
}
}
1 Like
oh thanks !!, I didn’t think about the coroutine: D