I'm trying to play sound on other clients, so they could hear gunfire in the distance, but sound only works for the shooter. Here's my code:
void Update()
{
***
if (Input.GetButton("Fire1"))
{
CmdFireWeapon(this.gameObject);
}
***
}
[Command]
void CmdFireWeapon(GameObject plr)
{
***
if (!plr.GetComponent<AudioSource>().isPlaying)
RpcPlayWeapon(plr);
***
}
[ClientRpc]
void RpcPlayWeapon(GameObject plr)
{
plr.GetComponent<AudioSource>().Play();
}
I'm using 3D Spatial Blend, but there's no sound even with volume == 1 across all distance. Also tried with and without if(isPlaying)
- no progress. What am I doing wrong?