Set up from Scratch
Options
Hello,
I am new to Photon Turn based.
Can someone post me simple steps to setup a room where 4-5 players can join. (With GUI).
Modified code from Memory Game (I am learning with that as reference)
[code2=csharp]public class GameClient : MonoBehaviour{
private LoadBalancingClient client;
public string AppID;
public int expectedMaxPlayers = 5;
void Start()
{
client = new LoadBalancingClient();
// "app-eu" is the European region. port 5055 for UDP (default).
client.MasterServerAddress = "app-us.exitgamescloud.com:5055";
client.AppId = AppID; // edit this!
client.Connect();
CreateTurnbasedRoom();
JoinRandom ();
}
void Update()
{
client.Service();
Debug.Log (client.CurrentRoom.Name);
//Debug.Log (client.CurrentRoom.Players.Count);
}
public void CreateTurnbasedRoom()
{
string newRoomName = string.Format("{0}-{1}", "Room1", Random.Range(0,1000).ToString("D4")); // for int, Random.Range is max-exclusive!
Debug.Log(string.Format("CreateTurnbasedRoom(): {0}", newRoomName));
RoomOptions roomOptions = new RoomOptions()
{
MaxPlayers = 2,
//CustomRoomPropertiesForLobby = new string[] { PropTurn, PropNames },
PlayerTtl = int.MaxValue,
EmptyRoomTtl = 5000
};
client.OpCreateRoom(newRoomName, roomOptions, TypedLobby.Default);
}
void JoinRandom()
{
client.OpJoinRoom("Room1");
Debug.Log (client.CurrentRoom.Name);
}
void OnGUI()
{
GUI.Box(new Rect(200,100,500,500),"This is it ");
}
}[/code2]
Basically I am trying to create a Lobby with a list of rooms. I realize that I have created a room and joined it by default.
But when I debug the players count it shows 0. At the same time it says im in Room1.
Goal: When I launch the player I need a Room list and an option to create or join rooms. Please help me set up this base connection. It will be helpful.
Thank you
I am new to Photon Turn based.
Can someone post me simple steps to setup a room where 4-5 players can join. (With GUI).
Modified code from Memory Game (I am learning with that as reference)
[code2=csharp]public class GameClient : MonoBehaviour{
private LoadBalancingClient client;
public string AppID;
public int expectedMaxPlayers = 5;
void Start()
{
client = new LoadBalancingClient();
// "app-eu" is the European region. port 5055 for UDP (default).
client.MasterServerAddress = "app-us.exitgamescloud.com:5055";
client.AppId = AppID; // edit this!
client.Connect();
CreateTurnbasedRoom();
JoinRandom ();
}
void Update()
{
client.Service();
Debug.Log (client.CurrentRoom.Name);
//Debug.Log (client.CurrentRoom.Players.Count);
}
public void CreateTurnbasedRoom()
{
string newRoomName = string.Format("{0}-{1}", "Room1", Random.Range(0,1000).ToString("D4")); // for int, Random.Range is max-exclusive!
Debug.Log(string.Format("CreateTurnbasedRoom(): {0}", newRoomName));
RoomOptions roomOptions = new RoomOptions()
{
MaxPlayers = 2,
//CustomRoomPropertiesForLobby = new string[] { PropTurn, PropNames },
PlayerTtl = int.MaxValue,
EmptyRoomTtl = 5000
};
client.OpCreateRoom(newRoomName, roomOptions, TypedLobby.Default);
}
void JoinRandom()
{
client.OpJoinRoom("Room1");
Debug.Log (client.CurrentRoom.Name);
}
void OnGUI()
{
GUI.Box(new Rect(200,100,500,500),"This is it ");
}
}[/code2]
Basically I am trying to create a Lobby with a list of rooms. I realize that I have created a room and joined it by default.
But when I debug the players count it shows 0. At the same time it says im in Room1.
Goal: When I launch the player I need a Room list and an option to create or join rooms. Please help me set up this base connection. It will be helpful.
Thank you
0
Comments
-
client.Connect();
CreateTurnbasedRoom();
JoinRandom ();
This won't work.
Connect establishes a connection with another machine. This takes a moment to setup and due to that, this is a process. You need to wait until this finishes.
We don't have a proper demo for the room lists in Turnbased but as the features and workflow are identical for Turnbased and Realtime, please take a look at the "Demo LoadBalancing" (folder demo-loadbalancing-unity). This has a room list in DemoGUI class. See OnGUILobby().
It will also be a good example how to connect, get into a lobby and create rooms. With GUI.0 -
HI, Thank you for the headsup.
I was looking into the script and found this.if (GUILayout.Button("Create", GUILayout.Width(150))) { this.GameInstance.OpJoinRandomRoom(null, 0); }
I am confused there, because from the documentation online says OpCreateRoom() to create a room?
*EDIT - I got it working, I realized that the Master Server doesn't work When I change it to app-us.exitgamescloud.com:5055 from app-eu.exitgamescloud.com:5055.
Also in the Gameplay section of tutorial, the explanation for Send and Recieving messages/events across the players is not sufficient. I set up GUI using the loadbalancing demo and memory demo. I have established connection. Now I wnat to send data across the players, update data etc.0 -
Hey I figured almost all the issues I mentioned.
The demoscene we should check is from the sandbox project. I figured out everything completely and to answer my question if someone else reads this. The answer is RoomInfoList from loadbalancing. Check out the sandbox demo and u will learn hwo to use it.0 -
Thanks for the update and cool you could figure out everything.0