top of page

The Scripts

Here you can see the Destroy by Boundaryscript, which connects the bondary lines with all other objects. The object used was a collider and whenever anything, an asteriod or the player, tried to go past it, they are destroyed. This keeps our inventory from filling up in Unity. If it wasn't there, the objects would just pile on and possibly crash the game. about you.

This is the Destroy by Contact script. This allows the asteriod to be destroyed by the shots and the player to be destroyed by the asteroids. 

 

One part of this script triggers the explosions of teh asteriods and player. When they are hit, the script makes the exposions go off where ever the object was destroyed. 

 

Another section of the script makes the score increase when an asteroid blows up. It also then destroys the explosion and asteriod after a certain amount of time. 

 

This script also is connected to the Game Controller script, and they silently talk back and forth, exchanging information and reactions. about you.

Just like in the Roll-A-Ball game, Space Shooter needs a Player Controller script. This script controls what buttons on the key board allow you to move and shoot and makes the player move across the game field. 

 

Part of the script puts in a speed and a fire rate variable. We got to pick just how fast our player would move and how fast it can produce shots. Some people had their fire rate at zero, which allowed them to just hold down the space bar and shoot out an infinite amount of shots. Others set a time between each shot. 

 

This script also plays the game's sounds, like the sound of the shots coming out of the ship. more about you.

The Mover script simply allows any object it is applied to to move. It gives the object a rigidbody and a speed variable. This was applied to our player, asteroid and enemy players. 

Put simply, this script, Random Rotator, randomly rotates the asteriods. Instead of the asteriods just moving down the screen slowly and stiffly, this script makes them rotate and spin. It can make them harder to hit as well. you.

This last script is the Game Controller script, and it is so important and long, that it needed two pictures! 

 

The beginning of the script controls the texts. It tells the Game Over, the Restart and the Score Text just what to do and when to do it. 

 

It also controls the waves of asteriosd that come down. When we first started, we had only one asteriod coming down right in the middle of the screen. Now, because of this script, there are ten asteriods spawning at random places on the game field. 

 

The script allows the game to restart with just a click of a button, and makes the words "GAME OVER" pop up whenever your ship is exploded.

 

The score is updated through this script and the words put up and change exactly when it's told to. 

bottom of page