UMG button click load level not working

I converted the game to 4.7 from 4.6.1
In 4.7 UMG button to start play level is working in UE Editor but not in the actual game.
What happens is when I click “PLAY” button it attempts to load the level but flashes screen black and goes back to menu screen.

Are there any important News in 4.7 Blueprint that I need to change to make it work?

see screenshot below


One advice: debug it. Check that execution step by step. Then you will know which operation fail.

Had the same problem. I did two things to make it work, unfortunately I’m not sure which of them fixed it:

  1. In 4.6 my maps where in “Content/Level/” folder and everything was working. In 4.7 Project Launcher wasn’t able to see them until I’ve moved them into the root of the content folder. So check first that Project Launcher can find your maps.
  2. I’ve made an empty project in 4.7 and migrated all of the content. Had to do it anyway as there were some issues after I’ve removed a lot of assets that I don’t need.
    Unfortunately I don’t remember which of these two did the trick.

@Nawrot
How do you debug packaged project?

I’m pretty sure I saw somewhere that maps are supposed to be in Content/Maps. At least I have mine there and it works.

Strange, I do this in 4.7 and it works. And my levels are in the maps folder.

For me it broke when I’ve opened 4.6 project in 4.7. If project was made in 4.7 then it works fine.

Ah, mine was originally in 4.6.1 and I moved it to 4.7.

But looking at it again, doesn’t your remove from viewport need a target?

self, as target, no (?)

You need to remove your UMG Widget BEFORE you open map.

So I suggest that you redesign the AddToViewport and RemoveFromParent where they are called. My suggestion is to use the PlayerController to Add and Remove the Widget before Open Map is called.

Just wanted to add there is of course another way to do it and to ensure that really ALL Widgets are removed from parent before loading the level

&stc=1

Use your Base Class or User Widget if you have no custom for your derived BP Widgets. Loop through all and Remove them and than open the level.

Now with this approach you don’t need to think of all the Widgets you added and need to be removed. But of course they all need to derive from the same Base Class.

You needed a target when you created the widget (menu) so it stands to reason you need that when removing it. Just drag a reference to the menu widget in there and connect it.

I add and remove widgets before and after loading a map… works fine. How else would you show a loading screen while the level is loading? Though more recently I simply set them to hidden and visible rather than recreating them over and over.

Hey Arbopa

Sorry for the short answer, was already late here.

Basically I assume you are constructing and removing the same widget at the same time. There were reports of crashes on AnswerHub (I had it also) when not removing all the Widgets before opening a map. Now with 4.7 I don’t know and I tried to find something in the release notes that Widgets being handled differently while opening a map.

In my games, I usually use GameState or PlayerController, since they are loaded up very early during loading a map. What I basically do is that the first State will be Loading and adding my loading screen to the viewport. My suggestion would be, that the Construction and Adding to the Viewport of your Menu/Loading Screen , is happening during the Event Begin Play of the Player Controller, since its local and not replicated and will represent the player being interfaced locally.

Than I would remove the Viewport before opening the map. Now since the Player Controller will be loaded again very early, it will construct your Menu/Loading Screen and adding to the viewport very early. There shouldn’t be any delay.

Here my example:

Now to have a true transition phase between levels I think it is only possible to do so in Code. But that is based on my assumption of looking through the code atm, I just am starting out implementing that behavior. The only Game Mode-like Class that would live between levels would be the GameInstances.

Hope it helps clarify my answer a bit better. Sorry for that again.

I have impression that both me and Domi109 followed the same tutorial where creation of MainMenu widget is done in level blueprint and destruction is done from inside of the widget itself after Open Level node. Which potentially is the source of the problem.
You are right Martin, doing it from the PlayerController should be a better way of handling MainMenu and level loading. Are you using separate PlayerController just for “out of the game level” interactions? Something like a default simple version of PlayerController for MainMenu and settings screen of the game.

Hey

No at the moment I use the same Player Controller, but I am considering to use a different one for the menu and for my Puzzle Game in the future.

But at the moment I am not using Player Controller, but GameState, which I actually don’t really like.

Essentially I would do it in the PC, but there is still a question open in the forum where I am trying to figure out if handling most UI stuff actually in the HUD Class since it is also instantiated per Player. But yeah. Ideally though it should be possible (Talking Blueprint) to have Widgets traveling with you, or at least a type of UUserWidget that is able to, for things like loading screens.

I was doing some stuff in 3ds max, now back to it.
Yes I was looking at the MainMenu tutorial with widget done in level blueprint.
I will give it a shot from PlayerController.