After following on the tutorial on creating MarcoPolo game at: Pun 2 0 - Introduction | Photon Engine , when i build and run the game between two instances, the movements of the monster characters are not synced as it is explained in the tutorial.
In OnjoinedRoom method() am instantiating the prefab as follows:
GameObject monster = PhotonNetwork.Instantiate(“monsterprefab”, Vector3.zero, Quaternion.identity, 0);
After instantiating the character, I activate CharacterControl and CharacterCamera:
voidOnJoinedRoom()
{
GameObject monster = PhotonNetwork.Instantiate(“monsterprefab”, Vector3.zero, Quaternion.identity, 0);
CharacterControl controller = monster.GetComponent();
controller.enabled = true;
CharacterCamera camera = monster.GetComponent();
camera.enabled = true;
}
The I send and receive Position and Rotation:
usingUnityEngine;
usingSystem.Collections;
publicclassNetworkCharacter : MonoBehaviour
{
publicvoidOnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if(stream.isWriting)
{
// We own this player: send the others our data
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
}
else
{
// Network player, receive data
this.transform.position = (Vector3) stream.ReceiveNext();
this.transform.rotation = (Quaternion) stream.ReceiveNext();
}
}
}
I downloaded the monster character from the provided link and the prefab exists in the Resources folder as explained.