Audio
Initially we started with the sounds for the Asteroids, this would be the explosion sound for the asteroid. To do this the audio file for the explosion needs to be dragged onto the Asteroid explosion prefab, the information for the audio would then appear in the Inspector panel.This was then repeated with the player explosion, and all that needs to be checked is that "Play on Awake" is ticked on both of those.
The next audio would be for the player's weapon, all that needs to be done is to drag the audio onto the Player within the Hierarchy, and then "Play on Awake" un-ticked because the sound wasn't to be played on load of the game but when a bolt is shot. To make the sound play when the bolt was shot the Player Controller script was edited, and all that was added in was audio.Play.
And finally with the audio we balanced out the sounds so they weren't all the same volume, this meant changing the player's weapon and background music to 0.5, and the explosions to be kept at 1 because they should be quite loud.
GUI Text
Next we created a few different GUI Texts for the screen; these were for the score, game over, and to let the player reset the game. To begin with a new Game Object needs to be created and renamed to "DisplayText" this is so that theres a place to keep all the texts together. Next three more Game Objects need to be created called "Score Text", "GameOver Text", and "Restart Text".First to "ScoreText" use the Add Component button to add a GUIText to the game object, and its kind of a case of playing around with the anchor, alignment, and pixel offset to get it to appear on the screen. For the space shooter game the best option was:
And then do the same for the other two Game Objects, once again playing around with the options until they are in the correct place or like the following:
Next the script for the Game Controller had to be edited to get the score up and running, plus in the DestroyByContact script some additional coding relating to the GameController had to be added to make the points appear when the asteroid is hit.
DestroyByContact:
GameController:
Then within the GameController's Inspector each of the GUITexts need to be linked in to the script, plus Game Over and Restart need to be ticked to allow them to be used.
And that's the game done.
No comments:
Post a Comment