Our team is developing a two-player cooperative platformer game played locally on a single device, sharing a gamepad. We are looking for a way to make sounds heard differently based on the position of each player character.
Our current idea is to “assign Listener A and B to each character, pan A to the left and B to the right to separate their respective sounds.”
In this case, we want to avoid using Spatializer for shared sounds or “background music” separated into bus tracks, so they play centered.
Is it possible to configure specific bus tracks to be heard only by Listener A?
We are using Unity version 6000.0.42f1.
This is a common misconception with how listeners function - a listener doesn’t act as a discrete entity that “hears” sound in space, but rather as a position/orientation/velocity in space that sound is spatialized (i.e. panned and attenuated) based on. If you use multiple listeners, each listener’s attributes will be blended together in order to create that spatialized signal.
I’m not sure exactly what you’re looking to do in your case, but there’s a number of ways to have a signal be spatialized based on a single listener:
- Use Studio::EventInstance::setListenerMask on event instances at runtime to set them to only consider specific listeners - this affects spatialization as well as built-in parameters, which you can use to automate other behavior like panning if need be
- Use Studio::System::setListenerWeight to specify how much a specific listener influences the mix globally
- Calculate the distance between your event instances and each listener at runtime, and use the resulting value to drive a parameter that automates panning for an event instance or bus i.e. panning left/right for listeners A and B, or blending between