Hello, this is my first attempt to code a multiplayer game, but all players that try to join the game get in different rooms, what did i do wrong? Code (csharp): public class Network : Photon.MonoBehaviour{ void Start () { PhotonNetwork.ConnectUsingSettings("test"); } void OnGUI () { GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ()); GUILayout.Label("Ping: " + PhotonNetwork.GetPing()); } void OnJoinedLobby() { PhotonNetwork.JoinRandomRoom(); } void OnPhotonRandomJoinFailed() { PhotonNetwork.CreateRoom(null); } void OnJoinedRoom() { if(GameObject.Find("plate1").GetComponent<Controls>().selected==false) { GameObject.Find("plate1").GetComponent<Controls>().plate=GameObject.Find ("plate1"); GameObject.Find("plate1").GetComponent<Controls>().selected=true; } else { GameObject.Find("plate2").GetComponent<Controls>().plate=GameObject.Find ("plate2"); GameObject.Find("plate2").GetComponent<Controls>().selected=true; } if(GameObject.Find("plate2").GetComponent<Controls>().selected==true&GameObject.Find("plate1").GetComponent<Controls>().selected==true) { GameObject.Find("Ball").GetComponent<ballmove>().start = true; } } }
Got rid of useless stuff and it worked guess the create room settings changed it though Code (csharp): using UnityEngine; using System.Collections; public class NetworkManager : Photon.MonoBehaviour { void OnJoinedLobby() { PhotonNetwork.JoinRandomRoom(); } void OnPhotonRandomJoinFailed() { PhotonNetwork.CreateRoom(null,new RoomOptions() {maxPlayers = 2},null); } void OnJoinedRoom() { Vector3 spawn = new Vector3 (7.5f,0f,0f); GameObject npl = PhotonNetwork.Instantiate("plate1",spawn,Quaternion.identity,0); npl.GetComponent<Controls>().plate=npl; npl.GetComponent<Controls>().selected=true; } } }