UMG Widget visibility control per level

Hi,

I apologize if this is same question over and over again, but I wasn’t able to find solution in available answers.

I’m trying to create ScoreUI widget that is only visible in specific levels. Reason I’m doing it is I want it to be hidden in my mainMenu level and visible in my gameLevel.

So I faced two problems:

  1. Where would you create your widget in this scenario? I thought if I will create instance in playerBP it will not be spawned in empty level, but empty level spawn all actors that I have and it creates scoreWidget as well. So I just created widget in my controllerBP and decided I will set visibility of the widget based on a level.
  2. When I’m trying to set visibility in level BP in eventBeginPlay my cast to controllerBP fails for some reason. Potentially it either not spawned yet , or controller is spawned but it hasn’t created instance of widget yet.

At first I thought my interface is not working but I setup actionButton and when I press it my interface triggers visibility change just fine.

What is the best practice approach in this case?

I actually solved this by having two different game modes for menu levels and game levels

Yes, another approach, but took too long to explain :slight_smile:

I wonder in your approach would you put game on pause and spawn menu on top of active level?

Again, correct.

A menu doesn’t constitute any load, so you can place it on top of anything. The system also needs to be able to cope with the player spamming the menu key ( they might change their mind a couple of times etc ).

The player controller is always available. I use mine to control the menus and level streaming.

Just write the code to choose when to show the main menu in the controller.

BTW: Seeing as the menu is just UMG, it doesn’t need a level of it’s own.

I actually solved this by having two different game modes for menu levels and game levels.
I wonder in your approach would you put game on pause and spawn menu on top of active level?
I noticed they do this in a lot of tutorials. They just create widgets for menus on top of currently active level.
I thought this is not best practice as if levels would be heavy, you probably wouldn’t want to load a level until player selected Start game or load game in the menu, right?