Fmod Unity Multiplayer 3d audio sync issue

Hi, I am facing an issue while syncing the player footstep 3d audio for a multiplayer game. The 3d audio is not working on distance based approach. I am trying to achieve that one player footstep audio should fade as he move away form another player position.
I am using Fmod for unity 2.02.11 version.
We tried " set3DAttributes" and “FMODUnity.RuntimeManager.AttachInstanceToGameObject” function approach but it is not working
Any suggestion on how to sync distance based audio for multiplayer

Hi!

Do you have a listener on both players? If so, you’ll be hearing an audio signal from both listeners at the same time, and the footstep audio wouldn’t fade as it’d always be playing at the same position as one of the listeners.

If this isn’t the case, and you only have a single listener on the player that isn’t moving away, can I get you to provide a snippet of the code where you’re handling your footstep event instance and using EventInstance.set3DAttributes() or FMODUnity.RuntimeManager.AttachInstanceToGameObject()?

Hi! @Louis_FMOD
Thanks for the response, We have listener on both players as it is a multiplayer network base FPS(First person shooter) game, so the each player that is spawned on the server is having a Fmod listener and a event emitter to play the 3d audio while it moves. The issue that we are facing is to sync these player footsteps in such a way that only player near to the other player will be able to hear the footsteps 3d audio.
It would be helpful if we come to know how we can implement Fmod audio in a multiplayer server game, Also If there are any links to such examples made in Unity3d would be much appreciated.

Thanks

While you can create multiple listeners in a single FMOD system, listeners aren’t discrete outputs for the system, but are used alongside event 3D attributes to calculate audio spatialization. If you have multiple listeners, FMOD will blend between their positions for the purposes of spatialization, which is likely why distance-based attenuation of your footsteps audio isn’t working. For more info, I’d recommend taking a look at the Multiple Listeners section of our Studio 3D Events White Paper.

Typically how network multiplayer games work with FMOD is to use the server to manage and coordinate events, while each client creates their own local FMOD system when running the game, with a listener for the player using that client. That way, while all events (i.e. your footsteps event) are coordinated by the server and are then played on each client’s FMOD system, the only listener used for spatialization for each respective client is attached to the player of that client.

Hope that helps!

Hi @Louis_FMOD
Thanks for sharing the knowledge ,This definitely helped us in understanding the challenges with FMOD for creating server based Multiplayer games audio system.
It seems that Handling multiple listeners in FMOD for a server based multiplayer game is not a great solution over the unity3d core audio API.
FMOD is suitable for standalone games and best for " edit in real-time" audio for sound engineers.
Also there are hardly any resources available with respect to FMOD 3D audio sync over network.

My wording was a little unclear, so to clarify, by “use the server to manage and coordinate events” I mean that the server is handling the overall state of the game; it isn’t actually syncing audio data across the network, or transmitting event instances over the network. Each local client receives the state of the game from the server, and then the local FMOD System handles event creation and management based on that game state, and calculates what the local player hears. Handling networked audio using Unity’s audio system will essentially involving doing the same thing. The main exception to this, in terms of audio, is something like voice chat, which does actually transmit audio across the network.

You can considering this to be analogous to how networked games handle most things that fall under a single client’s perspective, for example rendering a single player’s point of view: the client receives the game state in some form, but it doesn’t render what every player connected to the game is viewing at once - it only renders what the local player is currently seeing.

Hi @Louis_FMOD
Thanks for the response, your explanation definitely clarify our concepts. We want to use FMOD in our project as we can see lot of potential in FMOD from both audio creation and implementation perspective. But we are somehow facing challenges to implement multiplayer 3d audio sync using FMOD. Having said that it would be helpful if you can share some sample project or links on how to implement the FMOD audio for unity multiplayer FPS game.

Thanks

Unfortunately, we don’t have any examples or sample projects that demonstrate how to implement FMOD Studio audio with Unity Networking. However, in practice it’s not too difficult to implement, and is similar to how you would handle other kinds of client-specific behavior like cameras - you need a way to check whether the current game instance and specific objects in it belong to the server, a client, or specifically the local player, and you can tie behavior to those checks.

For a very basic example, assuming you have a simple network multiplayer game using Unity’s Netcode for GameObjects package, such as the project created in this Netcode for GameObjects tutorial - to only enable a listener on the local player when it is spawned, you would put an if (isOwner) check in the inherited method OnNetworkSpawn() of the player object’s NetworkBehaviour script, which will check whether the object belongs to the local player. If the object does belong to the local player, then you create/enable a StudioListener component.

For any calls to the FMOD system or events i.e. event creation, setting 3D attributes or parameters, etc. you’d likely want to wrap your FMOD-related calls in a check to ensure that they’re only executed on clients, and not the server. For example, you can create a GameObject with a NetworkObject component in the center of the scene, add a script that inherits from NetworkBehaviour, and set it to enable a StudioEventEmitter and play and event in OnNetworkSpawn() only if the game is executing as a client with if (isClient).

With the above checks in place:

  • The server doesn’t add any listeners or create any events

  • All clients execute functions related to FMOD - event creation and playback, setting 3D attributes, etc.

  • Each local client creates a listener on their respective “player” GameObject, but not on any other player GameObjects

I hope that makes it a little clearer.

As an aside, I agree that there’s hardly any resources out there for implementing FMOD Studio in network multiplayer games, so I’ve flagged the creation of some kind of example or sample project on our internal feature/improvement tracker.

Hi @Louis_FMOD
Thanks for your active response and also for adding our request to create some examples to your " internal feature/improvement tracker".
We are actively working on implementing FMOD for multiplayer game using Unity.
Hope so we find a solution for our challenges at earliest possible!.

Thanks once again for your support, We will keep you posted on the progress according .

1 Like