For our programming exam we were tasked with using unity to create a slingshot game which involves the player shooting a spaceship through multiple targets before hitting the finish line.
Firstly I created a unity 2D project and added a space background with a spaceship (the player) and series of planets set up in an obstacle course.

I did this in 2D because it made it easier to maintain the forces acting on the ball (spaceship), this way it allowed me to make sure the player has one direction to move in and it made the map easier to create borders around by adding 2D colliders around the sides.

Secondly, I began adding the slingshot for the player next, I did this by creating a "Ball" script that would allow the player (spaceship) to be dragged around a set anchor point when the mouse is pressed down and to launch the spaceship (in the opposite direction that you dragged) you stop holding the mouse click.

Thirdly, The goal was added, this allowed the player to win because I created a script called "goal" that (once the player entered the trigger) would delete the player game-object (the spaceship) and show text of the player's time, high-score and telling the player that they have won. The player only wins the game when the player collected all of the targets and reached the finish-line.
Then, I started to add numbers onto the planets in order, this was used to show the order the spaceship would need to go past the planets to collect the targets that were going to be added.
Next, I added targets so that the player would have to pass the planets in a specific order, I did this by creating an array and counter that (depending on the number in the array) would spawn the target in different positions, if the counter went above 10 however, the targets would no longer spawn and would allow the player to win once they reached the goal.
The player would loose the game if they touched a planet or got to the goal without collecting the targets beforehand, when this happens text appears on screen telling the player that they lost and the scene restarts so the player can try again.
No comments:
Post a Comment