OnPhotonSerializeView() doesn't work
Options
Hi,
I'm working in a car game with multiplayer.
All works fine, master and clients are connected to the room fine. (I have been using Marco Polo tutorial)
The problem is when I see other cars moving in the screen, the position updates by teleporting the cars. Appears and disappears all the time.
Part of my code:
When I playing with 2 cars, In the first car I sometimes get this error: "IndexOutOfRangeException: Array index is out of range. PhotonStream.ReceiveNext ()..." In the line 100.
In the second car I get the same.
Could you help me please?
I'm working in a car game with multiplayer.
All works fine, master and clients are connected to the room fine. (I have been using Marco Polo tutorial)
The problem is when I see other cars moving in the screen, the position updates by teleporting the cars. Appears and disappears all the time.
Part of my code:
PhotonNetwork.automaticallySyncScene = false; public class CNPlayerManager : Photon.MonoBehaviour { ... void FixedUpdate() { if (photonView.isMine) { //it works fine } else { transform.position= Vector3.Lerp(transform.position, this.correctPosition, Time.deltaTime * 5); transform.rotation= Quaternion.Lerp(transform.rotation, this.correctRotation, Time.deltaTime * 5); } } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.isWriting) { stream.SendNext(transform.position); stream.SendNext(transform.rotation); } else { this.correctPosition = (Vector3)stream.ReceiveNext(); //Line 100 this.correctRotation = (Quaternion)stream.ReceiveNext(); //Line 101 } }My PhotonView in my car prefab is like this: but in my Photon Version I have more options. In Owner I have "set at runtime" and "Fixed". And in "Observed components" I have 2 components, my car prefab and the script CNPlayerManager.
When I playing with 2 cars, In the first car I sometimes get this error: "IndexOutOfRangeException: Array index is out of range. PhotonStream.ReceiveNext ()..." In the line 100.
In the second car I get the same.
Could you help me please?
0