Audio in Multiplayer at Players Location

New to the entire process and been wracking my brain over this one. I’ve got the audio triggering when a player fires their weapon, works great. Where I’m stuck is when other people in the game fire their weapons, all the other players being able to hear them at that at the location the weapon was fired if their close enough.

I’ve got an AudioSource attached to the playing characters with the AudioClip in it. I’m calling on it by finding it as a child in my FireWeapon script then doing;

I’m wondering how I’d write an RPC to be send out to the network that would tell everyone else the location the sound is originating. If code I have is needed, let me know.

C# if you post code, as that’s what I’m currently working with. Thanks!

So just send an RPC to the player to play the clip on the local object.

In your player script:

     function PlaySound() {
          if(networkView.isMine) {
                networkView.RPC("PlaySound", RPCMode.Others);
          //Play your sound on this character