Search Unity

Third Party Mirror and audiosources (shooting)

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

  1. Zeepblok

    Zeepblok

    Joined:
    Sep 26, 2015
    Posts:
    17
    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

    arufolo

    Joined:
    Mar 5, 2013
    Posts:
    8
    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

    FiveXGames

    Joined:
    Apr 27, 2016
    Posts:
    43
    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

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    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.