Menu to Pick your Character - User Interface for Unreal 5.5 New Series - UE5 UI
Adding a new menu, when the character spawns, to choose your character.
This introduces a chose between the Manny and Quinn characters in a single character setting.
This tutorial is a little bit longer than my typically tutorials, let me know if you prefer this longer format in the comments!
Written Commands:
Open BP_ThirdPerson Character
Create Custom Event ‘Swap Character’, Add Inputs SelectedCharacter type Integer
Save
Create New User Widget in Assets: WBP_CharSelect
Canvas Panel
Text: Manny (Anchor center, x:-140, y:-18, sizeX:100, sizeY:30, Justify:Cen, Behavior Not Hit-Testable)
Text: Quinn (Anchor center, x:40, y:-18, sizeX:100, sizeY:30, Justify:Cen, Behavior Not Hit-Testable)
Text: Select Your Character (Anc cen., x:--48 y:-48, sizeX: 100, sizeY:30, Justify:Cen, Behavior Not Hit-Testable)
Manny Button (Anc cen, x:-150, y:-15, sizeX:120, sizeY:30, Events:OnClicked)
Quinn Button (Anc cen, x:30, y:-15, sizeX:120, sizeY:30, Events:OnClicked)
Go to Graph,
On Clicked Quinn - Cast to BP_ThirdPersonCharacter
Get Player Character (leave index 0) to plug into Object for cast
Pull off Cast and call custom Swap Character event
Connect blue pin from Cast to Swap Character, leave Selected Character as 0
On Clicked Manny - Cast to BP_ThirdPersonCharacter
Get Player Character (leave index 0) to plug into Object for cast
Pull off Cast and call custom Swap Character event
Connect blue pin from Cast to Swap Character, change Selected Character to 1
Save & Compile
Open the BP_ThirdPersonCharacter again
Create Custom Event ‘CharacterSelect’
Create Widget, Set Class to WBP Char Select
Pull off return and promote to variable: Char Select WBP
Pull pin off to Add to Viewport
Set Input Mode Game and UI
Player Controller is Get Player Controller (index 0)
In Widget to Focus is Char Select WBP (Hid Cursor During Capture is checked (doesn’t matter))
Set Show Mouse Cursor (check box)
Target is Get Player Controller (index 0)
Pull pin to Set Game Paused
Between Event and Create Widget, insert Validated Get for Char Select WBP - Is Not Valid is this stream
Can also consider doing a validated get for the Main Menu (WBP menu) to make sure this menu isn’t active when this function is called
If not valid - move to validated get for Char Select WBP
If is Valid: Remove from Parent
Set Main Menu as void Set Input mode game only (player Controller is get Player Controller 0)
Set Show Mouse Cursor (unchecked) target: Get Player Controller (index 0)
Set Game Paused (unchecked)
From Swap Character create a branch
Set the branch to 0 == selected character from custom event
True Pin goes to Set Skeletal Mesh Asset (mesh connected as target)
New Mesh set to SKM_Quinn
False from Branch goes to another Branch
Set the branch to 1 == Selected Character from custom event
True pin goes to Set Skeletal Mess Asset (mesh connected as target)
New Mesh set to SKM_Manny
False goes to Print String (incorrect selection) which should never happen
All three branches then merge to Remove from Parent
Target is Char Select_WBP
Set Char Select WBP to null
Set Input Mode Game Only (Get Player Controller (index 0))
Set Show Mouse cursor (unchecked) Get Player Controller (index 0)
Set Game Paused (unchecked)
Go to Level Blueprint
Event Begin Play
Cast to BP_thirdPersonCharacter (get player character index 0)
Call Character Select BP_thirdPersonCharacter as target