Download

Fatal error when switching level in packaged game

Hello! I’m new to UE4 and I’ve just packaged my first game. However during testing I ran into a problem. It seems to crash whenever I switch levels. The interesting thing is that it only crashes in the packaged version of the game. The map that I’m switching to is the ElvenRuins map which is one of the InfinityBlade assets. The code:

void AMainCharacter::ChangeLevel(FName LevelName)
{
UWorld* World = GetWorld();
if (World)
{
FString CurrLevel =World->GetMapName();
FName CurrLevelName(*CurrLevel);
if (CurrLevelName != LevelName)
{
UGameplayStatics::OpenLevel(World, LevelName);
}
}
}

The function is called when the main character overlaps with a box component. The name is definetly correct on the blueprint (I mean it works in the editor). The only settings that I’ve changed for packaging is that I’ve set Build Configuration to “Shipping” and turned on “Create compressed cooked packages”. I’ve already tried rebuilding all the “Intermediate” and “Saved” folders. Didn’t help. Any ideas why is this happening? Thanks!

Hey zablas,

I see you’re changing level by Level Name. That method of level change is fine, but when Unreal packages game assets it doesn’t detect assets that need to be packaged if they are only referenced by name. In editor this will work fine because in that mode you have access to every asset.

Go to Project Settings > Packaging. There you’ll find a list of maps to cook and you’ll need to add the ElvenRuins map, as well as any other map that is solely referenced by name.

Are you talking about the “List of maps to include in a packaged build” option? If yes, then I simply have to add the .umap files through the file picker window right?

I believe including the .umap files has worked. Thank you!

No problem. :slight_smile:

You are passing this message on to me, do you know why? I would appreciate it if you can help me