I am trying make a multiplayer game where you join someone else’s scene, different from your scene. Whenever I try to join the other player’s room it loads the game objects from my scene not the other player. I am trying PhotonNetwork.automaticallySyncScene to sync the scenes. I see the other player when I join the scene but I don’t see enabled game objects. You can see the players move on both screens. In the first picture the red cube is enabled in the scene before the start and only one person can see it. In the second picture the player can’t see the red cube. I have tried adding photon views to the cube but it doesn’t seem to work. So is there anyway I could make the player joining have the same scene and game objects as the MasterClient.
Here is my network coding.
public class NetworkManager : MonoBehaviour {
private bool joinRoom;
void Awake () {
if (!PhotonNetwork.connected) {
PhotonNetwork.ConnectUsingSettings ("V1.0");
PhotonNetwork.automaticallySyncScene = true;
}
}
void Update(){
if (PhotonNetwork.insideLobby && Application.loadedLevelName == "Scene1") {
createRoom();
}
}
public void joinRandom(){
PhotonNetwork.LeaveRoom ();
joinRoom = true;
}
void OnJoinedLobby(){
if (joinRoom) {
PhotonNetwork.JoinRandomRoom ();
joinRoom = false;
}
}
void OnJoinedRoom(){
InstantiatePlayer ();
}
void InstantiatePlayer(){
GameObject player = PhotonNetwork.Instantiate ("Player", new Vector3(0, 2, -6), Quaternion.identity, 0) as GameObject;
player.GetComponent<Player> ().enabled = true;
player.GetComponentInChildren<Camera> ().enabled = true;
}
void createRoom(){
PhotonNetwork.CreateRoom (PlayerPrefs.GetString ("HouseName"));
}
void OnPhotonRandomJoinFailed(){
Debug.Log("No Rooms");
}
void OnGUI(){
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
}
}