Create game instance (for UI related stuffs e.g. join,create session, because it’s
only local, won’t get replicated, but persistent in entire game even change map):
In framwork, BP → type gameinstance, name as BP_Shooter_Gameinstance
Go to project setting, choose the gameinstance created:
Create Framework BP:
Create new gamemode base, pawn and controller for menu page:
Set gamemode menu base BP as follow:
Create a new folder called menu in Map folder
Add a new level, choose Blank, save and name as MainMenuMap
Add a 2nd level, choose Basic, name as LobbyMenuMap
In lobby map, set gamemode override in world setting, as BP_shooterMenu_Gamemode
Repeat the same in MainMenu Map
Create Widget for main menu:
Create Widget named WB_MainMenu
set button style of tint color differently at normal, hovered and pressed
Add Spacer (size Y 15) between each button
Open GameInstance BP
Add new function called UI_showMainMenu, creat the nodes, and new variable called WB_MainMenu
Create Widget node, choose the class and connect to set variable:
Continue:
Open Main Menu Map BP (in main menu level, click below), set the nodes:
Now start the game, will open from main menu widget page
Back to WB_MainMenu Widget, set Quit game and Solo Game buttons graph:
Set follow in GameInstane BP, event graph for Solo game button:
Back to WB mainmenu widget graph
Create Player Controller in Solo Game character movement
In Framework folder, create Player Controller BP, name BP_shooter_PlayerController
Open Shooter_Shooter Gamemode Base, change the Playercontroller to the one created
Open new player controller, event graph
Save player profile whenever connect the server, can just load it out:
Open a folder called SavedData in Content, create a structure, name S_PlayerProfile
Open it and rename as:
Create BP class, type SaveGame, name as SG_PlayerProfile
Open it, add variable:
Go to Gameinstance graph, add new function CheckForSavedProfile,
promote variable on slot name, rename it as PlayerProfile_Slot, type it on Default value box too
Add function “LoadProfile”, connect graph (get player profile at end)
Promote to variable, name as Player Profile_Info, result:
Add new function as SaveProfile (if no previous profile saved can be loaded, will create a new save game)
Back to CheckforSaved funciton, set branch if go to load profile or save new profile
Go to WB_MainMenu Widget, create a new border for player:
change editable text name as Input PlayerName
Go to its graph, add on text committed
Back to GameInstance, event graph, add custom event and add input variable as Playername:
Go to UI ShowMain Menu funciton to add nodes before return node (to be sure name in text box if old player profile found)
Back to WB_MainMenu Widget graph