First, I designed this to be a component, so that it could be added to any character with a reasonable amount of animations (be it player, enemy, or otherwise). This component, the AnimationSoundManager, had access to that character's avatar, and this avatar held information about what animation was currently playing. Thus, my class looks for when a new animation is played, and checks if there is an associated sound file for it. If so, it plays the sound, and waits for a new animation to activate. I give thanks to Blake who suggested a system for storing the previous animation to compare with the current one to see if a new animation had triggered.
However, I ran into a little problem. I had no way to shut off looping sounds from my AudioController class. Thus, I restructured that class as well to include a way to delete clips from the previous animation. I also programmed a function that cleaned up clips that had completed. Previously, they still existed even after they finished, but now they are properly removed. This should prove much more efficient down the road. Additionally, I programmed a simple mute functionality that would either un-mute or mute all current clips when called (i.e. it reversed the current mute setting).
Another problem arose when I realized that the Windows version of our game doesn't switch animations (because we only use a cube for our character on Windows). This proved an obstacle in seeing if the AnimationSoundManager was actually doing its job. To overcome this, I had to manually program changes in the Cube's current animation (though this change was strictly to notify me when to play a sound). I decided to keep these changes in, so that anyone playing on the Windows version would be able to hear animation sounds.
In the end, this worked out well. We now have various sounds in our game to give it a little more life. Even though most of these sounds are placeholder, they add to the experience nonetheless.
This comment has been removed by the author.
ReplyDeleteI like post. Thanks for sharing.
ReplyDeleteCybergraphix