Hey, sorry for my bad english.
here’s my problem… now I’m try to make Multiplayer Stuff with Photon Unity network
right now, I can spawn a player and each player can’t see each other
next I’m try to let the player instantiate a Cube from the scripts ( not a prefab ) and move them
[PunRPC] public void CreateObj(int objID) { id1 = PhotonNetwork.AllocateViewID(); if (objID == 1) { sphere = GameObject.CreatePrimitive (PrimitiveType.Sphere); sphere.AddComponent<PhotonView> (); sphere.AddComponent<NetworkCharacter> (); PhotonView pv = sphere.GetComponent<PhotonView> (); pv.synchronization = ViewSynchronization.UnreliableOnChange; pv.ObservedComponents = new List<Component>(); pv.ObservedComponents.Add(sphere.GetComponent<NetworkCharacter> ());
the problem is each player can Move them BUT each player can see another player’s object movement
which mean the Object that have been spawn remain the same position in another player screen
I tried to do few things and i assume that I have to used 2 method which is RPCs to send a new Position of that object look like this
[PunRPC]
void OnGizmo(int selectID, float AmountToMove)
{
Debug.Log (selectID +","+AmountToMove );
target.transform.Translate (axis * AmountToMove, Space.World);
// PhotonView.Find(selectID).transform.Translate (axis * moveAmount, Space.World);
PhotonView.Find(selectID).transform.position = new Vector3(target.transform.position.x,target.transform.position.y,target.transform.position.z);
}
and another method by ‘void OnPhotonSerializeView’
void OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info)
{
Debug.Log ("isStream");
if (stream.isWriting) {
Debug.Log ("isWriting");
stream.SendNext (transform.position);
stream.SendNext (transform.rotation);
} else {
Debug.Log ("isReading");
FirstPosition = (Vector3)stream.ReceiveNext ();
realRotation = (Quaternion)stream.ReceiveNext ();
}
}
which I already attached to Observe Components list BUT stream.isWriting are not firing after I tried to Debug it and I don’t sure why this happen and how to fix it,
Anyone have any suggestion PLEASE let me know I really need you guys, THANKS!