Today, sound effects! Specifically laser hitting something sound. Now since this is gonna require an asset I don't already have I am gonna need to find it somewhere on the Internet. Shouldn't be terribly hard. After messing around on Google I finally find a quick little sound effect that sounds good enough and name it Hit.wav (originally an mp3, but the tutorial mentioned you had to do something special with mp3s and there is no reason to get fancy with a small sound effect like this.
After loading the sound effect asset and declaring/initializing it I tell it to play in the collision method when it subtracts the health of the player/enemy for a laser hit. Now, technically this will make it play even when the enemy dies, but I want to see how that sounds before I decide whether I need an if statement to tell it to only play if the player/enemy is still alive.
I get a build file saying that Hit.wav couldn't be opened. Possibly because it is not in the asset folder and I told it to load it from the desktop. Also note to self, all of the Shooter files and content are in documents -> Visual Studio 2010, don't look in program files or anything. That wasn't the problem, when I added it to Shooter it copied it to the content folder. Apparently either the sound effect was too small for the game to recognize it as a sound effect or there was some DRM?
After getting a different sound effect from a different site it was perfectly fine. So it was something with the file and not the code. Tested it and it worked fine.
Not sure what I'll work on next time, might just have a free day where I mess around with the code.
No comments:
Post a Comment