Actually, every sound is currently played at the exact same volume. That was fine for the old BASTON, but now that 32 fighters can punch simultaneously across a huge terrain, the punching sounds quickly become unbearable.
I’ll start by localizing sound relative to the camera, so the farther a sound is from the camera, the lower its volume.
What I’m still wondering, though, is how sound is handled when there are multiple cameras, like one per human player (up to four players).
How do games like Super Smash Bros. Brawl deal with that?
I just remembered that there is only one camera in Super Smash Brawl., so it's not a good example.
I can compute the average volume for a sound per player camera:
var vol = 0.0;
for (cam in playerCameras) {
var dist = FlxPoint.distance(soundPos, cam.scroll);
vol += 1.0 - Math.min(dist / maxDist, 1.0);
}
vol /= playerCameras.length; // Average volume
I can also do the same to pan the sound left/right based on horizontal position relative to player average.
var pan = (soundPos.x - camera.scroll.x) / camera.width;
pan = Math.max(-1, Math.min(1, pan));
Pages: 1