NMNW
1
I have six different bullet, and its have different fill time.
When the every ten seconds,there will be bullets fired.
But do not know how many bullets will be fired.(maybe one bullet , or two different bullets etc.)
Can give me some idea or code?
I thought about using InvokeRepeating() & Random
But bullets fill time how to apply it?
just writed code, for understanding.
IEnumerator BulletFirer()
{
while (firing)
{
float timeStarted = Time.time;
int bulletsCount = UnityEngine.Random.Range(0, 5);
for(int i = 0; i < bulletsCount; i++)
{
int bulletID = UnityEngine.Random.Range(0, 6);
InstantiateBullet(bulletID)
yield return new WaitForSeconds(GetFillTime(bulletID));
}
yield return new WaitForSeconds(timeStarted + 10f - Time.time);
}
}