ASTEROIDS - INVOKE REPEATING
The asteroids are now instantiated randomly at random position. However, a slight error was made. The Instantiate method was called in Update() method. This made our game have asteroids generated every frame. The whole screen was populated with the asteroid. To avoid this, instead of calling SpawnAsteroids() method in Update(), we can use InvokeRepeating() method in Start().Â
InvokeRepeating()
This method invokes certain method after certain time the game started and at a given interval of time.
Declaration:
string methodName = "SpawnAsteroids"
float time = 1f (1 second after game started)
float repeatRate = 2f (repeats the method every 2 seconds)
...PROGRESS SO FAR...