I’ve just started to learn Unreal Engine and I developing a Pong game using C++.
To create the menu I have used UMG and to learn how to do it, I have watched Wiring up the Main Menu tutorial from Unreal Engine Online learning.
To show the Widget with the menu the instructor has created a new empty level and he has used Level Blueprint to
show it. But the instructor said: “Traditionally, you don’t use the level Blueprint for much”.
So, if we don’t have to use the level Blueprint, what do I have to do to show the main menu?
I usually store it as a property on the PlayerController and haven’t had any issues doing that. The reason is that you’ll always have a PC spawned on each level and I route all my input through the PC so it makes sense to me. There are two things that should launch a main menu:
The player via keypress (A “LaunchMainMenu” function on the PC)
The main menu level (the default map that opens when launching the game, menu is launched from level blueprint’s BeginPlay)
The only thing that they have in common is the core gameplay framework (GameMode, PC, Character etc.) and least amount of effort for me is putting it in the PC. Maybe for you it might be the Character, up to you really.
For me it was hard to see the big picture. Level blueprint is just made for you when you create a level. If you have one level it’s easy and fast to set it up and have your BP code there without creating a new BP. It’s quick and dirty to test and demo. With bigger games with many levels and pause menu. You want to keep everything clean, small code, code that does not repeat, commented. It’s better if you have 1 widget master that you can get different customized children. 1 widget and you call it from 1 BP instead of having many widgets and calling it from different BPs. It doesn’t really matter where you put it. It can be on Player Controller, On Character, game instance, game mode, custom master BP, custom BP lib, main menu level if you plan not to use the code anywhere else. You want to avoid writing same code in main menu level and then writing same code in player controller to get pause menu. Try to keep to this rules, but don’t stress it. Eventually you will get used to it and the engine. I still make a bunch of same code and copy them and later sit and combine them to make 1 function and giving it enum to switch. Or 1 master BP. This will come to you don’t get overwhelmed. Just focus on making small code that achieves same goal.