0

I am beginner to photon on unity3d. I want to move character synchronously in a game. I am attaching script as an observer to the photon view and using this code

void OnPhotonSerializeView(PhotonStream stream,PhotonMessageInfo info)
{
    if (stream.isWriting)
    {
        Debug.Log("writing");
        stream.SendNext(transform.position);
        stream.SendNext(transform.rotation);

    }
    else
    {
        Debug.Log("reading");
        this.correctPlayerPos = (Vector3)stream.ReceiveNext();
        this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
    }
}

The problem is that the player who creates the room can change the position and rotation of player, it can only write. But the second player(who joins the rooms) cannot change the position and rotation,it can only read. What can be the problem with my setup.

I have followed the marco polo tutorial(http://doc.exitgames.com/en/pun/current/tutorials/tutorial-marco-polo) for this. Any help is highly apperciated.

Aqeel Raza
  • 1,729
  • 4
  • 15
  • 24

1 Answers1

0

If you instantiate a GameObject per player via PhotonNetwork.Instantiate, then each client has it's own(ed) GameObject which this client can write updates for.

Tobias
  • 164
  • 2