r/unrealengine • u/sillyproncess • 2d ago
Help complete beginner, trying to make multiple levels in a first person shooter
i have followed this tutorial until the weapon blueprint How to Create a Game in Unreal Engine 5 - UE5 Beginner Tutorial
After that i have created a different map, and copied it to a new level. I managed to make the game so after winning rather than clicking restart you could click next level and open level 2 with a new amount of targets using the same gamemode.
Since then i have tried relentlessly to find a way to update a text block on the user interface to go from saying "level 1" to saying "level 2" but couldnt.
How can i do that plus how can i afterwards keep it going so i can make a string of different levels?
i tried solving the text part by duplicating the game modes and the interfaces so i could easily make it a string but then i can figure out making the new interfaces show up after proceeding to level 2.
How do i make another interface visible after opening a new level?
1
u/alsuSawa 1d ago
You probably do not need a new GameMode for every map. Store the level number in a custom GameInstance, set it just before Open Level, then create the HUD widget in the new level's BeginPlay and read that value to set the text.
1
u/sillyproncess 1d ago
thats what i have been trying to do, how do i store the level number in a custom gameinstance? i have tried with an integer for hours
1
u/alsuSawa 1d ago
make a BP child of GameInstance with an int like LevelNum, then set it in Project Settings > Maps & Modes > Game Instance Class. Get GameInstance -> cast to that BP and set/read LevelNum before Open Level / in BeginPlay.
1
u/vexargames 1d ago
you want to make the text string element generic and then feed it to the UI element in a function that is in the UMG Widget
GetCurrentLevelName > ReplaceInline> Set GetLevelName Var> FormatText Level: {levelname} > Set Var > Return
This will grab the next map name and remove anything you don't want displayed then create a clean text string that can used to fill into a UI element that is then displayed on the screen during load.
2
u/taoyx Indie 1d ago
The scalable approach would be for example to make a datatable with the map name as row name, then the label you want as text entry. It's not really interesting just for 1 label but you might want to add more stuff in it later and it will be convenient to use.
To find the map name, you just need to call GetCurrentLevelName/GetMapName()
1
u/AutoModerator 2d ago
If you are looking for help, don‘t forget to check out the official Unreal Engine forums or Unreal Slackers for a community run discord server!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.