Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

Multiplayer: Effects not syncing to all users

$
0
0
Hello, I have a problem with my gun muzzle effect not syncing across all users. The effect works and sends to clients when the server fires the gun, however when the client fires the gun it does not send to the server or any another client. Here is the code: [Client] void CmdShoot() { GetComponent().PlayOneShot(gunshot); anim.gameObject.GetComponent().Rewind(gunShotAnim.name); anim.gameObject.GetComponent().Play(gunShotAnim.name); ammo -= 1; Ray ray = cam.ScreenPointToRay(new Vector3(Screen.width * Random.Range(aimxx.x, aimxx.y), Screen.height * Random.Range(aimyy.x, aimyy.y))); RaycastHit hit; if (Physics.Raycast(ray, out hit, 500)) { if (hit.transform.gameObject.tag == "Enemy") { Instantiate(blood, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); hit.transform.gameObject.SendMessage("Hit", dmg, SendMessageOptions.DontRequireReceiver); } if (hit.transform.gameObject.tag == "Stone") { GameObject st = (GameObject)Instantiate(stone, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); NetworkServer.Spawn(st); } if (hit.transform.gameObject.tag == "Dirt") { Instantiate(dirt, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); } if (hit.transform.gameObject.tag == "Metal") { Instantiate(metal, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); } if (hit.transform.gameObject.tag == "Ragdoll") { Instantiate(blood, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); } } RpcMF(); counter = 0; } [Client] void RpcMF () { GameObject mf = (GameObject)Instantiate(muzzleFlash, muzzlePoint.position, muzzlePoint.rotation); NetworkServer.Spawn(mf); mf.transform.SetParent(muzzlePoint.transform); Destroy(mf.gameObject, 0.05f); } Any help would be appreciated!

Viewing all articles
Browse latest Browse all 592

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>