ASTEROIDS - BEHAVIOR

In this section, I will show you how I added moving behavior to the asteroids. Also, once the asteroids move away from the scene, it should be destroyed to save the memory of the game. 

BEHAVIOR: MOVE TOWARDS SPACESHIP

DESTROY SPACESHIP OFFSCREEN

The script now check if the objects are out of Bounds (upperBound for laser bullets and lowerBound for asteroids) and destroys the gameObjects that it is attached to.