Hi there !
I’d like to do a method that would Spawn boxes.
void Start()
{
InvokeRepeating("SpawnBalloon", 0, spawnRate);
}
void Update()
{
timeElapsed += Time.deltaTime;
if (timeElapsed >= spawnRateIncreaseInterval)
{
spawnRate -= spawnRateIncreaseAmount;
timeElapsed = 0f;
CancelInvoke("SpawnBalloon");
InvokeRepeating("SpawnBalloon", 0, spawnRate);
}
}
I did this, but there’s an issue as it sometimes spawns a box, then changes the spawnRate and spawns another one right away.
I’ve solved this using Coroutines instead. (Thanks Claude !)
But I was wondering then, what’s really best ? When do you use InvokeRepeating, and when do you use Coroutines ?
Thanks a bunch !