Making An Asteroid Shoot Towards The Player!
Apart from the enemy spaceships, I want some more dangerous things in my game. Let’s make some Asteroids to avoid!
Today’s Objective: Create an asteroid that spawns occasionally, shoots towards the player from a random angle, and the player must avoid otherwise they will die with 1 hit.
First, the prefab:
Create a new 2D Sprite GameObject called “Shooting Asteroid”. I’m going to use the same movement script as my enemy ships, since its mostly identical code, but add some modifications.
In the EnemyMovement script:
Now, moving to my SpawnManager script:
After adding the Asteroid to the new “Asteroids” spawn list on the Spawn Manager’s Inspector window, it combines with the rest of the game to make this: