Unity-Technologies/com.unity.multiplayer.samples.bitesize

client cannot hear firesound

Alexander5421 opened this issue · 2 comments

Describe the bug
The client fires a bullet, but only the host can hear the firesound.

https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blob/6e39bc28f5a1ef51f49324e9d46897e118adbd77/Basic/2DSpaceShooter/Assets/Scripts/ShipControl.cs#LL197C26-L197C26
I think this line causes the bug. Fire action is a FireServerRpc, So only the host executes this function.

This is my solution
[ClientRpc] void PlayFireSoundClientRpc() { fireSound.Play(); }
and replace the fireSound.Play(); with PlayFireSoundClientRpc();

I just strat to learn how to write multiplayer game code, So I am not sure whether this is a good practice

Hi @Alexander5421 ,
This work has landed into our workflows in this PR, and so I'll close this issue.

Thanks again for your contribution!