Crash when loading new level in packaged game

Version 5.2.

Hi, I have a main menu which so far just has a single new game widget button, which when clicked should load the main game level:

This works when playing in editor, but does not work in a packaged game. When packaged, the game loads, but clicking the button just says “Fatal Error!” and closes.

This is the end of the crash log, but I don’t know what would be wrong here:

The only thing I can think of is perhaps the level isnt being found or something, but I am not sure why it might work in editor, but not in a packaged game.

Any help would be appreciated!

Strangely, the log looks ok :-/

Have you tried using ‘open level by name’?

It’s easier, and it won’t generate a hard reference in the widget.

I have done some more investigating and the issue seems to be with the GameState in this new level. I believe I have a race condition where my PlayerPawn is calling a function from a factory class in my GameState, which isn’t actually being created until the BeginPlay of the GameState - which for some reason is always happening first in editor, but not in the packaged game.

Do you know how I can possibly set my factory from the editor defaults instead of creating new objects in C++?

This is what I have been doing up until now:

I would instead like to be able to set the factory classes directly from within my BP_GameState, but none of my factories are showing up:

I know this is because my Blueprint factories are not actually objects, but classes that need to be instantiated, but how can I make them objects that are avaliable before any BeginPlay() calls are made?

1 Like

I don’t have any ground breaking ideas there, I’m afraid.

Could you make your player wait until the class is valid?