- Home /
How can i make gun sounds play to all players? using photon.
Hello , I am making a 3d multiplayer game using photon. I added gun and its sounds to the game and player who shoots it can hear it but not the others. How can I make it so others hear the gun sounds as well?
Answer by GetLitGames · May 09 at 10:23 AM
When one player shoots, send an RPC to Others and in the RPC play the shoot sound. On the player, if you have a script on your player that inherits from MonoBehaviourPun you can do something similar to below. You can choose to either RPCTarget.Others or RPCTarget.All. Personally I tend to like to do something like below. That way the sound is played locally instantly
PlayShootSound();
photonView.RPC("PlayShootSound", RPCTarget.Others);
[PunRPC]
void PlayShootSoundRPC()
{
PlayShootSound();
}
void PlayShootSound() {
aud.Play(ShootSound);
}
https://doc.photonengine.com/en-us/pun/current/gameplay/rpcsandraiseevent
So thing is I am kind of a beginner at this, so I don't really understand where to write that code. :P
Your answer
Follow this Question
Related Questions
PUN is being incredibly slow in builds 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
PUN - Choose random Hero for player 0 Answers