using System.Collections; using System.Collections.Generic; using UnityEngine; public class NetworkedPlayer : Photon.MonoBehaviour { public GameObject avatar; public Transform playerGlobal; public Transform playerLocal; void Start () { Debug.Log("I am Networked Player"); if (photonView.isMine) { Debug.Log("photonview is mine"); //playerGlobal = GameObject.Find("CameraController").transform; //playerLocal = playerGlobal.Find("Dive_Camera"); this.transform.SetParent(playerLocal); this.transform.localPosition = Vector3.zero; //avatar.SetActive(false); //avatar = Resources.Load("NetworkedPlayer/avatar") as GameObject; } } void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.isWriting) { Debug.Log ("send the others my data"); // stream.SendNext(playerGlobal.position); // stream.SendNext(playerGlobal.rotation); // stream.SendNext(playerLocal.localPosition); // stream.SendNext(playerLocal.localRotation); } else { this.transform.position = (Vector3)stream.ReceiveNext(); this.transform.rotation = (Quaternion)stream.ReceiveNext(); avatar.transform.localPosition = (Vector3)stream.ReceiveNext(); avatar.transform.localRotation = (Quaternion)stream.ReceiveNext(); } } }