Synchronize with photon

Hello I'm a french developer using photon, but recently I integrate a camera in my fps was the first person and another in the third person.

The goal is that when the photon is a view I show the first person and third person I appear to the other player.

But the worry is that when I close the camera and another character that will synchronize well but lag, it creates a connection bug, I think it's just my synchronization script:



using UnityEngine;
using System.Collections;

public class PhotonNetworkSync : Photon.MonoBehaviour {

    


	// Use this for initialization
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            Vector3 pos = new Vector3();
            Quaternion rot = new Quaternion();
            pos = gameObject.transform.position;
            rot = gameObject.transform.rotation;
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
        }
        else if(stream.isReading)
        {
            Vector3 pos = new Vector3();
            Quaternion rot = new Quaternion();
            stream.Serialize(ref pos);
            gameObject.transform.position = pos;
            stream.Serialize(ref rot);
            gameObject.transform.rotation = rot;
        }
    }

    
}

So I hope to find help here, thank you!

Comments

  • I would try to help, of course but "it creates a connection bug" is not specific enough to help at all.
    In worst case, try to go through the Marco Polo Tutorial once more and try to modify it step by step into a prototype for your game.
    http://doc.exitgames.com/en/pun/current ... marco-polo
  • Thanck for you answer but I already try marco polo method, and I use the same script and there in the bug Forever
  • As said: You have to describe the bug in more detail.
    What is in the log, how do you produce it, what's happening?