Unity - Adding audio and finishing the game

Adding sounds to asteroids 
I added audio to my asteroid by adding an audio component to the explosion prefab and then importing the specific audio clip in the inspector. Below I selected PLAY ON AWAKE so the sound clip would only play when the asteroid is shot.  


In the player controller script I added audio.Play();. This allows background music to be added to the overall scene. I selected PLAY ON AWAKE and LOOP so the music would play as soon as the game starts and loops until the game is closed, I can also change the volume and pitch in the inspector.




Score
I created an empty game object and to this I added a gui text called SCORE TEXT, this will show how many the player has scored.



In the script GameController code needs to be added to relate the text to how many times the asteroids are shot and destroyed.




After I added that code it then allowed me to add the score text by dragging it into the score text section in the inspector. This process was repeated for the restart and game overtext.



All text I put into quotation marks will show on the game as that, rather than restartText for example.



And there we are! My basic game is now finished. Now I will try and customise my game to make it a bit more personalised and to learn new game making techniques for myself!


No comments: