Friday, October 9, 2015

Unity Day 19 (Space Shooter Project)

What I Did:

     Today I begun by figuring out the error. I have been unable to figure out how to properly cache and give the GetComponent<AudioSource> ().Play (); a simplified form so I used It's full form to replace the audio.Play. Although this Isn't optimal I had to do it in order to move on with the tutorial so the code currently stands as:

if (Input.GetButton("Fire1") && Time.time > nextFire) 
{
nextFire = Time.time + fireRate;
Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
GetComponent<AudioSource> ().Play ();
}

     Now that the laser fire makes proper sounds every shot, I added background music by dragging and dropping the background music file onto the player controller game object in the hierarchy. Then making sure the play on awake section was ticked so it would begin playing when the game started, and loop was ticked so that the music would keep playing.

What I Learned:

     I learned how to make sound effects play when the player activates and action, and how to add music to a game.

What I'm Doing Next Day:

     Next Day I will be adding a scoring system that counts points when asteroids are destroyed. 

No comments:

Post a Comment