Multiplayer Game Series (Pt 1 -character)

Part 4 - Lobby Menu



Fix Mp_menu from part 3:


Add Refresh list if searching no result

Go to MP menu WB, on clicked Bttn Search Game,
add refresh set text node from For Each Loop Completed output:
image.png

Change Btn Connection type (now it starts solo game):
image.png

Go to Gameinstance BP, IsLanConnection variable
tick default value to true
image.png
Open Change ConnectionType function, return node, rename its output as IsLanGame
image.png

Create Lobby Menu


Duplicate MainMenu WB, name as WB_LobbyMenu
Recreate the widget (bttn_Mainmenu set as variable)
image.png

Go to BP MenuController, event graph
Add custom event (endclientsession)
To start replicate things between host and clients, by host tells clients end their sessions:
change replciates to Run on Own Client
image.png
image.png

Back to LobbyMenu WB, event graph, clear all old nodes and recreate:

Create MainMenu button function:

image.png

Go to BP_Menu_Gamemode, even graph, add variable All_ConnectedPlayers
image.png

Back to Lobby menu, continue the graph
image.png

Create Start Game button function:


Go to Gameinstance event graph, add custom event TravelToMap, then promote to variable
image.png
make the graph below
(Add space after typing severtravel on append node)
image.png

Back to Lobby menu, on clicked Bttn_StartGame
image.png

Create event construct (make sure joiners go to lobby map from lobbymenu, when they are on server) in LobbyMenu
(promote variable from make array node, name as All Borders Player Name and AllTextPlayerName)
image.png
Rename startgame bttn and change to variable in Designer
image.png
Continue the branch false graph if not in server
image.png

Show Lobby Menu at Startup:


Go to MenuController BP, event graph
Add function name as UI_ShowLobbyMenu
image.png

Back to event graph, add custom event and replicate, connect to function just created:
image.png
image.png
at event begin play node
image.png

Go to Menu_Gamemode event graph, type event handle starting newplayer
Add pin name manually in Switch on String node
(for if new player enter session, will return to player controller)
image.png
image.png

Test now, should be server click host game, will get into lobby (show start game)
client search game, find it, connected, get into lobby too (show please wait)
image.png
client can click main menu if not waiting, and reconnect by clicking search Game
Host click main menu will destroy session both himself and clients.

Load and display Player names on Screen


Go to BP MenuController
Add a function called LoadSaveProfile
Take same slot name as from Gameinstance “PlayerProfile_Slot”
image.png
In gameinstance:
image.png

Continue the graph for branch (when saved game existed, if not, create one)
image.png

Back to event graph, create a new custom event, called Initial_Setup , replicate on owning client
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.