- Home /
Question by
masonporter21 · Mar 13, 2015 at 08:09 PM ·
networkingmultiplayerfps
Showing Player weapon over the network
Hello, reader. I am currently making a multi player fps on unity 4.6. I have just learned how to switch weapons, but when I was about to test the weapon on the network, I saw that the weapon visual actually didn't carry over. Here is my code, starting on line 35:
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
if(stream.isWriting) {
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
stream.SendNext(anim.GetFloat("Speed"));
stream.SendNext(anim.GetBool("Jumping"));
stream.SendNext(anim.GetFloat("AimAngle"));
stream.SendNext(this.gameObject.GetComponentInChildren<WeaponData>().weaponID);
}
else {
realPosition = (Vector3)stream.ReceiveNext();
realRotation = (Quaternion)stream.ReceiveNext();
anim.SetFloat("Speed", (float)stream.ReceiveNext());
anim.SetBool("Jumping", (bool)stream.ReceiveNext());
realAimAngle = (float)stream.ReceiveNext();
weaponID = (float)stream.ReceiveNext();
if(gotFirstUpdate == false) {
transform.position = realPosition;
transform.rotation = realRotation;
anim.SetFloat("AimAngle",realAimAngle);
gotFirstUpdate = true;
}
}
}
Is there a problem with my script? If so, how do I fix it (P.S: My attempt to fix it is the weaponID = float blah blah blah junk. Also, if you can't tell, I am using Photon Unity Network for my server.)
Comment