# Lobby Setup

This guide will walk you through the steps required to set up a lobby from scratch using the built in Kronos lobby classes.

The [**Example Content**](https://horizongames.gitbook.io/kronos-matchmaking/examples/example-content) that is shipped with the plugin has a fully functioning **KronosExampleLobby** map. If you do not want to worry about setting up your own lobby, feel free to use the example lobby map found in "/Plugins/Kronos/Examples/Maps/".

## Setting Up The Lobby Level

### 1. Creating The Lobby Level

Let's start by creating the lobby level itself. Go to **File -> New Level** and select the "Basic" level.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2F1l1nXijMUpg8H8vjM6SP%2FLobby_CreateNewLevel.jpg?alt=media&#x26;token=233c590c-8049-4fc6-8caa-c1dcf5aab580" alt=""><figcaption></figcaption></figure>

### 2. Adding Player Starts

Players who join the lobby will spawn on `PlayerStart` actors. By default the level contains only one player start which won't be enough for all players. So let's add a few more to the level. The minimum amount of player starts needed is based on your game's max player count.&#x20;

{% hint style="info" %}
For example a **4 player coop** game will need **4 player starts**.
{% endhint %}

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2FM6odEzZ7WaSZzTTr4Prz%2FLobby_AddPlayerStart.jpg?alt=media&#x26;token=c9a831d0-da82-4a2d-8c29-d69f3d88754e" alt=""><figcaption></figcaption></figure>

## Setting Up The Lobby Classes

### 1. Creating the Lobby Game Mode

Create a new blueprint from the `KronosLobbyGameMode` class and open it. Inside the **Details** panel on the right, you will see a "Lobby" section. From here you can configure things such as lobby wait times and the minimum amount of players required to start the game.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2FcMf3NYLTml7279WGfuF2%2FLobby_GameMode.jpg?alt=media&#x26;token=9ee02b64-bbc7-424c-ba48-e648daf015f6" alt=""><figcaption></figcaption></figure>

Now that we have the game mode, we need to assign it to the level. With your lobby level open, go to **Window -> World Settings** and set the "GameMode Override" to your lobby game mode.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2FqIYQtzE0mBBqQgfhuEQZ%2FLobby_OverrideGameMode.jpg?alt=media&#x26;token=9d0ff2a2-fa14-44f1-88a8-c2e6a89ccb26" alt=""><figcaption></figcaption></figure>

### 2. Creating the Lobby Game State

Create a new blueprint from the `KronosLobbyGameState` class and open it. Here you can configure whether to relocate players when they join. If enabled, players in the lobby will be moved around locally between player starts, so that everyone will see their own character on the same spot in their screens.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2Fo7ISpit1ehpNLL0Paq57%2FLobby_GameState.jpg?alt=media&#x26;token=9c5e9ecb-d5c7-4ae8-9fbc-b32cb673a46c" alt=""><figcaption></figcaption></figure>

The "Local Player Start Tag" defines which player start should be used for the local player. We need to set this tag for one of our `PlayerStart` actors. To do this, simply select the player start in the level and set its "Player Start Tag" to the same tag as in the game state.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2F22crq6GwD3E2v4CI8RHr%2FLobby_SetPlayerStartTag.jpg?alt=media&#x26;token=49d0199f-0b79-4e87-b30d-aa216c5880bf" alt=""><figcaption></figcaption></figure>

### 3. Creating the Lobby Player Controller

Create a new blueprint from the `KronosLobbyPlayerController` class and open it. Here you can configure whether to override the view target or not. If enabled, players will view the lobby from the perspective of a pre-placed `Camera` actor in the lobby level.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2FWpE3OLr4UT8SOBkMRejN%2FLobby_PlayerController.jpg?alt=media&#x26;token=57849bdc-a40a-4dc5-8872-81f5590fd49f" alt=""><figcaption></figcaption></figure>

By default, the first available camera will be used as the view target. If you have multiple cameras in your lobby level then you can enabled the "Find Camera By Tag" option and specify which camera should be used via the "Camera Actor Tag". Let's go back to our lobby level and place a `Camera` actor.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2F0OSG9hBgJb41yP4ZJs7z%2FLobby_AddCamera.jpg?alt=media&#x26;token=18271559-3cf9-4ef2-9198-5fcfadd89dfd" alt=""><figcaption></figcaption></figure>

After adding the camera to the level, select it and make sure that the "Auto Activate for Player" option is disabled. I also recommend disabling the "Constrain Aspect Ratio" option to avoid black bars from appearing at different screen resolutions.

If you have the "Find Camera By Tag" option enabled in your lobby player controller, make sure to add your "Camera Actor Tag" to the camera's **Actor Tags** list.

### 4. Creating the Lobby Player State

Create a new blueprint from the `KronosLobbyPlayerState` class. This class is responsible for storing the ready state of the player. We actually do not need to do anything in this class for the lobby to work.

### 5. Creating the Lobby Pawn

Create a new blueprint from the `KronosLobbyPawn` class. This will be the player's character. If you open the blueprint you will see that it does not have a character mesh by default. I'm going to go ahead and add a `SkeletalMeshComponent` to it, and select a basic character asset.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2FmK60suohYGuAqQt1AhmW%2FLobby_PlayerPawn.jpg?alt=media&#x26;token=c645f52f-035d-46b8-9a24-f9f447a663d4" alt=""><figcaption></figcaption></figure>

I'm also going to add a `KronosNameplateComponent` to the pawn. This component renders a widget above the character's head automatically. For the widget class, I'm simply going to use the "WBP\_KronosExampleLobbyPlayer" which is part of the [**Example Content**](https://horizongames.gitbook.io/kronos-matchmaking/examples/example-content) shipped with the plugin. It will display the player's name and ready state. Feel free to copy this widget into your project and customize it to your liking.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2FQgH4Hrd8TQqf4ulAIiy2%2FLobby_Nameplate.jpg?alt=media&#x26;token=f4927bf9-a5b0-4110-849c-b76bdf6824d7" alt=""><figcaption></figcaption></figure>

### 6. Creating the Lobby HUD

Create a new blueprint from the `KronosLobbyHUD` class. This class doesn't have any options that we can change. Instead we will use this class to add a lobby widget to the screen and change the input mode in the lobby.

For the lobby widget I'm simply going to use the "WBP\_KronosExampleLobby" which is part of the [**Example Content**](https://horizongames.gitbook.io/kronos-matchmaking/examples/example-content) shipped with the plugin. This widget has the player ready button, and leave lobby buttons set up automatically. Feel free to copy this widget into your project and customize it to your liking.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2Fp48kDBpM1znvxBEvBTzR%2FLobby_AddLobbyWidgetToScreen.jpg?alt=media&#x26;token=439702d4-aeac-4804-acf4-5c84f70ace32" alt=""><figcaption></figcaption></figure>

### 7. Assigning the Lobby Classes to the Game Mode

Now that we have created all the lobby classes we need to go back to our lobby game mode and assign the new classes.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2FWFHWbZbAfj0ALGp7PlFO%2FLobby_SetClassesInGameMode.jpg?alt=media&#x26;token=2447da55-da4f-4a6a-85ff-55067f5783fc" alt=""><figcaption></figcaption></figure>

## Finishing Touches

There's only a few steps left to do that I'm simply going to sum up here.

### 1. Setting Players Ready

The "WBP\_KronosExampleLobby" widget already has this implemented, but you can find more information in the [**Set Players Ready**](https://horizongames.gitbook.io/kronos-matchmaking/usage/lobby/set-players-ready) section of the documentation.

### 2. Starting The Match

When all players are ready and the match is started, you will need to initiate a server travel to a new map where the match will be played. The [**Starting The Match**](https://horizongames.gitbook.io/kronos-matchmaking/usage/lobby/starting-the-match) section of the documentation explains this in more detail.

### 3. Leaving The Lobby

The "WBP\_KronosExampleLobby" widget already has this implemented, but you can find more information in the [**Leaving The Lobby**](https://horizongames.gitbook.io/kronos-matchmaking/usage/lobby/leaving-the-lobby) section of the documentation.
