This week, I'm going to write a brief technical devlog on how I have set up volume control options in Monumental Failure. Let's first show our final result. Pretty typical sound options eh? In my implementation, the SFX and music channels can be affected individually, and the master will affect them both. I've also made the decision that 70% volume will be "normal", allowing the user to both decrease and increase volume. Our first step is to create an Audio Mixer. The audio mixer will have 1 group to start, I have named mine "Master". I then create two subgroups called Music and SoundEffects. You of course can create more groups as you need. For each group, you must expose the volume variable to script by right clicking and selecting Expose. I'm not going to give details on how to do this next step, but there are two things you need in your scripts. The first is a reference to each of the AudioMixerGroups in your AudioMixer. This lets you set the volume variable you just exposed. The second is to ensure when your game plays audio, it is routed to the appropriate AudioMixerGroup. I solve these problems by having an audio controller class that stores references to the AudioMixerGroups. When I want to play a sound my scripts call a method in the audio controller which assigns the appropriate AudioMixerGroup. The final step is translating the percentage in the Options menu into a value for volume. You will have noticed that the AudioMixerGroups have volume which can be set from -80 to +20 decibels. Decibels create a problem. Decibels work on a logarithmic scale, which means +10 is loud, and +20 is really really loud. Similarily anything below about -40 is nearly inaudible. How do we choose what decibel values our volume percentage translates to? My solution starts by declaring a minimum DB, maximum DB and normal DB percentage (70% as mentioned above). const float MAX_DB = 10f; Here's where it gets a little ugly. I have a method that passes in a volume percentage as a float between 0 and 1. If that value is greater than my default percentage, I'll linearly interpolate between 0 and my max volume, otherwise, I'll use a circular out interpolation to find a value between 0 and my minimum volume. public void SetMasterVolume(float iVolume) Perhaps if my memory of how logarithmic scales work I could find a method better than this ugly code, but sometimes you just have to go with what works. Let me know if you have a better solution, or if my solution helped you!
Cheers, Spencer
0 Comments
This week I worked on adding a cooperative play mode to Monumental Failure. If you have 2, 3, or 4 local players, you can play through any level together, working on a single monument. Fun! I've mentioned before that I've been borrowing from local multiplayer game design, I thought today I'd take a moment to discuss why. There's a game interview podcast I listen to where the host routinely asks the guest "what game has made you laugh?" I think there's a lot of insight into the state of comedy and games contained within this question. Asking it to myself, I'm immediately tempted to list the comedic games I've played. Games with good writing, absurd premises, and silly designs. Games like Just Cause, Octodad, or Jazzpunk. Funny games. While I have huge respect for design and achievements of those games, I feel that if I'm being honest with my answer, I can't really say these games made me laugh. Maybe a chortle here, a snicker there, and plenty of wry smiles, but never the full gut busting laugh. For me, the games that make me laugh most are the games I play with my friends. With my friends, in the same room, specifically. Certainly there are the games designed to elicit comedy, something like Gang Beasts or a Jackbox game. But beyond the explicitly comedic, there is so much comedy to be found in the stories a game tells. Think of the comeback earned by a bullshit weapon pick up, the assured mutual loss ("I can't win and so you won't either"), getting hilariously screwed out of sheep in Catan, or whatever other story the game might tell. In the right context, with the the right friends, you have the potential not just to laugh, but create lasting memories. Monumental Failure is supposed to be funny. From my experience, the way I can guarantee the humour resonates is to encourage playing it with friends. Be it competitive, cooperative, or maybe even asynchronously via a stream or video. Accounting for all the local multiplayer options guarantees more work for me, but I'm confident it will pay off.
Thanks for reading, Spencer |
Archives
March 2017
Categories |