Space Invaders

Space Invaders by danielRift (itch.io)

The clamp keeps the player locked on the y axis and limits their movement on the x axis to prevent them from moving off screen. When the bullet is spawned it checks that the time that has passed is more than nextFire which is the bullet cooldown time.

Enemy code

The enemies only need to move down constantly so Vector3.down can be used for this as it is an in built function for constant downward movement. The if statement destroys the enemies if they move off screen.

Collisions with the player
Bullet code

The FMOD music event is assigned to the variable music – a variable is a name for a memory location that holds a value – this starts when the scene starts and is stopped immediately when the player is killed to prevent the track overlapping with itself each time the game restarts.

Leave a comment

Your email address will not be published. Required fields are marked *