Lobby Setup
Last updated
Last updated
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 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/".
Let's start by creating the lobby level itself. Go to File -> New Level and select the "Basic" level.
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.
For example a 4 player coop game will need 4 player starts.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 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.
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 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.
Now that we have created all the lobby classes we need to go back to our lobby game mode and assign the new classes.
There's only a few steps left to do that I'm simply going to sum up here.
The "WBP_KronosExampleLobby" widget already has this implemented, but you can find more information in the Set Players Ready section of the documentation.
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 section of the documentation explains this in more detail.
The "WBP_KronosExampleLobby" widget already has this implemented, but you can find more information in the Leaving The Lobby section of the documentation.