- Home /
Question by
absolutegames1 · Jul 28, 2013 at 09:33 AM ·
multiplayercrosshair
C# OR Java- Multiplayer Shoot Sound
Hi guys and girs. I need help. I have a multiplayer game, followed by remix games tutorials and now i want to add something to my player so it can shoot. I added a simple script when i press mouse button it plays a sound but it only plays for the multiplayer server player(me) and for others that are playing with me they cant hear the sound. I also added a crosshair but only i cant see it other players cant see it . Please help. Thanks ahead Here is the shooting script i used( its in java but i can use c#) : #pragma strict
var shot : AudioClip;
var fireRate : float = 1.0;
private var nextFire : float = 0.0;
private var t : Transform;
function Start () {
t = transform;
}
function Update () {
if (Input.GetButton("Fire1") && IsOkToShoot()) Shoot();
}
function IsOkToShoot () : boolean {
var itsOk : boolean = false;
if (Time.time>nextFire) {
nextFire = Time.time + fireRate;
itsOk = true;
}
return itsOk;
}
function Shoot () {
AudioSource.PlayClipAtPoint(shot, t.position);
}
Thanks ahead .
Comment
Add an RPC call to all buffered players so they get the message to play the sound.
Your answer
![](https://koobas.hobune.stream/wayback/20220613111036im_/https://answers.unity.com/themes/thub/images/avi.jpg)