Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Third Party Mirror and audiosources (shooting)

Discussion in 'Multiplayer' started by Zeepblok, Jan 6, 2021.

  1. Zeepblok


    Sep 26, 2015
    Hi all,

    Quick question. I have a multiplayer FPS game everything works (so far). There is one thing however I cant figure out. When a player shoots he hears a shooting sound. Only thing is the other clients don't hear it. How can I make it so the audio plays on all clients so they hear each other shooting. I googled a bit but can't find anything that helps me. Who can point me in the right direction?
    arufolo likes this.
  2. arufolo


    Mar 5, 2013
    Sorry for the necro... You ever figure this out? I'm having the same problem and the Mirror documentation mentions nothing about audio
  3. FiveXGames


    Apr 27, 2016
    There multiple ways, for example when calling the shoot method, just add a network call (client, server...) inside that is "PlayShootAudio" so the other clients will reproduce the sound because of the network call. Other option is to use the shoot method itself.

    As a rule remember that a client doesn't know anything about the server or other clients if they are not "notified" about it. For example, when using synchronized elements is just a shortcut that will "notifiy" others without you worrying about it.
    Joe-Censored likes this.
  4. Joe-Censored


    Mar 26, 2013
    It depends on how your bullets work. If you have a visual representation of the bullet, like a bullet prefab you spawn across all clients already, you could consider just attaching the sound to that object. If you don't, but you have a muzzle flash object, that also makes a good candidate.
    FiveXGames likes this.