PhotonNetwork is a popular multiplayer game development platform that provides turnkey solutions and tools for both small and large scale gaming projects. PhotonNetwork has a feature called CreateRoom which allows developers to create a playable room for players to join.
Example 1: Creating a Room with default settings
// Set default values for RoomOptions RoomOptions roomOptions = new RoomOptions();
// Create a new room with a random name and the default options PhotonNetwork.CreateRoom(null, roomOptions);
In this example, a new room is created with no specific room name and with default settings.
Example 2: Creating a Private Room with Custom Settings
// Set custom values for RoomOptions RoomOptions roomOptions = new RoomOptions(); roomOptions.IsVisible = false; // hide room from lobby roomOptions.MaxPlayers = 4; // set max players to 4 roomOptions.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable {{ "level", 3 }}; // add custom room property level with value 3
// Create a new private room with a specific name and the custom options PhotonNetwork.CreateRoom("myRoom", roomOptions, TypedLobby.Default);
In this example, a new private room named "myRoom" is created with custom settings such as being hidden from the lobby, having a maximum of 4 players, and a custom room property "level" with a value of 3.
C# (CSharp) PhotonNetwork.CreateRoom - 30 examples found. These are the top rated real world C# (CSharp) examples of PhotonNetwork.CreateRoom from package PaperCowboys extracted from open source projects. You can rate examples to help us improve the quality of examples.
Creates a room with given name but fails if this room is existing already.
If you don't want to create a unique room-name, pass null or "" as name and the server will assign a roomName (a GUID as string). Call this only on the master server. Internally, the master will respond with a server-address (and roomName, if needed). Both are used internally to switch to the assigned game server and roomName. PhotonNetwork.autoCleanUpPlayerObjects will become this room's AutoCleanUp property and that's used by all clients that join this room.