GameDev : Asteroid (Part I)!
To make things a little more “difficult”, let’s now create an Asteroid which, after being hit and destroyed, start the wave of Enemies!
It’s not so complicated, but is a good exercise to create new mechanics and make it functional in the Game!
And we start to think to how solve this type of problems!
Every times we start with simple mechanism : we need to hit Asteroid for starting waves, so drag the Asteroid into the Scene.
Give it a starting position, like this
And maybe a little rotation over time
As we see, we need to rotate it on Z Axis.
To set up Asteroid, we need a Circle Collider 2D (edit it a little because is too big), and we need the Rigidbody 2D for collision with Laser.
Set gravity to 0 and check the Trigger toggle
Now that we have set up the Asteroid in scene, create the behaviour for it
And attach it
Open the script.
First, because we need a starting position, I prefer cash it.
To rotate it
transform.Rotate() is a good method.
It’s not the only one, but to make the Asteroid rotate in one direction I think is a easy and fast way.
No need something incredible here, a simple rotation over time.
This is the first step, in the next we make the Asteroid EXPLODE!!