• Twitter
  • Facebook
  • Google+
  • RSS Feed

Thursday, 12 March 2015

Interactivity 7- Adding sound effects and text

No comments:
 
During today's lesson we were shown how to add sound effects such as asteroid and ship explosion sounds and pieces of text to our game i.e. score count and game over text.

We began by adding sound effects to our asteroid explosion and ship explosion.

 Adding a component to my explosion prefab under the 'Audio' section, selecting 'Audio Source'. 

 'explosion_player' sound effect added to our 'explosion_player' prefab. 

 'explosion_asteroid' sound effect added to our 'explosion_asteroid' prefab. 

'explosion_enemy' sound effect added to our 'explosion_enemy' prefab. 

I then started adding text to my game by importing 3 different texts by creating a new 'UI  > Text' 


Three created UI text's

We then edited our 'GameController' text to allow our text in game and for our 'ScoreText' to change as you hit the asteroid prefab. We also added a restart function using the 'RestartText' we created. The 'Void Start()....' allowed for the number to increase when you shoot an asteroid, along with the 'Public void AddScore'. The 'if (restart)...' function allowed for the 'R' key input to restart the game, with the if statement under it referencing to the text saying 'Press 'R' to Restart' (RestartText in our game). 


I then edited all my pieces of text by moving it to the correct position and setting the size, font, color and so on.


'Game Over' settings.

We then added more pieces of code to our 'DestroyByContact' script. The coding below allowed the score value to increase when you shoot the asteroid. The 'GameController' variable allows the functionality of the 'AddScore' variable. 



This was our last lesson with Luke and I feel confident using Unity now, and I plan to go off and customise my game further. 

No comments:

Post a Comment

 
© 2012. Design by Main-Blogger - Blogger Template and Blogging Stuff