Packaging game breaks everything. Urgent problem.

I just started using UE about half a year ago and I made small tech demo as my portfolio, using UE 4.24, C++/Blueprint. The project is nearly done, but I can’t package the game properly because of major bugs exclusive to packaged game and not presented in PIE/Launch-In-Editor(Idk what the actual name is, the big button right after PIE).

Firstly, all of my UE_LOGs doesn’t work. First I suspected it’s because LogTemp is omitted in packaged game, so I replaced the LogTemps to bunch of custom log categories, like so:



DECLARE_LOG_CATEGORY_EXTERN(LogRoomGen, All, All);


And it did nothing.
I also saw adding some text in DefaultEngine.ini does something in some old (and maybe obsolete) post, so I tried added following line to the config:



[Core.Log]
LogRoomGen = All
LogRoomGenGame = All


And it did nothing. Also I tried to add this:



[Core.Log]
global = All


But apparently the engine spits out hundreds of error about blueprint class being weird and blocks from packaging, so I couldn’t even get my game packaged with this option.

Secondly, all of my Widget UIs doesn’t appear. Two widgets are created and added to viewport at BeginPlay in level blueprint and none of them appears. I didn’t tried anything about this issue, since I have no idea what is possibly causing the issue and, apparently, I am the only living organism in the universe experiencing this sort of issue about UI, according to Google.

Thirdly, game doesn’t use the camera that already presented in level. It is registered with ‘Set View Target with Blend’ at BeginPlay in level blueprint. But in packaged game, it’s completely ignored and replaced with other camera. I guess the camera is attached to controller, since it follows movement of player pawn?
The camera is nothing special. The camera actor is atttached to different actor, and the actor monitors location of the player pawn and adjusts its position every tick.

Lastly, the room is not properly generated. It’s code-related issue so I will try my best to explain without overexplaining.
This game uses procedural generation to connect presets of rooms into one giant stage, much like Binding of Isaac. The room is stored in form of level asset. The level is loaded once player enters the room, and unloaded when left the room.
After loading room level into the world, the room is ‘initialized’ for gameplay - Creating door and connecting into other rooms, moving player pawn to its initial position, spawning room objectives, like that. Door is created after room generation as separated entity to not to slap the door in dead end, and to differentiate special rooms by adding different doors in front of it - again, like Binding of Isaac.
The former works great. The problem comes in latter, room is never initialized; Door isn’t there, player pawn spawns in (0, 0, 0).
Now, it’s natural to suspect some sort of coding error caused by some mistakes. But bear in mind, all of this isn’t occurring outside packaged game. Following is short summary of the code that causes this odd behavior:



void AAbstractRoomGenerator::Spawn(){
  if(!SpawnedLevel){
  auto level = GetLevel();
    if(!level.IsNull()){
      bool succeed = false;
      SpawnedLevel = ULevelStreamingDynamic::LoadLevelInstanceBySoftObjectPtr(this, level, FVector::ZeroVector, FRotator::ZeroRotator, succeed);
      if(succeed){
        SpawnedLevel->SetShouldBeVisible(true);
        AwaitingFinishSpawn = true
      } else{
        UE_LOG(LogRoomGen, Error, TEXT("Idk how but failed to load level into the world"));
        SpawnedLevel = nullptr;
      }
    } else UE_LOG(LogRoomGen, Error, TEXT("Couldn't generate without level specified"));
  } else UE_LOG(LogRoomGen, Error, TEXT("Room already spawned"));
}


I know this function is called because the level is loaded, which this function does. And it marks AwaitingFinishSpawn to true, which is used in following code:



void AAbstractRoomGenerator::Tick(float DeltaTime){
  Super::Tick(DeltaTime);
  if(AwaitingFinishSpawn){
    if(SpawnedLevel->IsLevelVisible()){
      AwaitingFinishSpawn = false;
      FinishSpawn();
    }
  }
}


If AwaitingFinishSpawn is true, the Room Generator checks if the level is visible, then calls FinishSpawn.



void ARoomGenerator::FinishSpawn(){
  auto w = SpawnedLevel->GetWorld();
  if(auto h = ARoomHandler::FindRoomHandler(w)){
    h->Initialize(Room, UGameplayStatics::GetPlayerPawn(this, 0), SpawnSide);
  } else{
    UE_LOG(LogRoomGen, Error, TEXT("Because room handler failed to be found, the level will be unloaded."));
    SpawnedLevel->SetIsRequestingUnloadAndRemoval(true);
    SpawnedLevel = nullptr;
  }
}


ARoomHandler::FindRoomHandler is utility function that searches given world for actor ARoomHandler and returns it.
The important part is ‘Initialize’ part, if it’s called, then the door should be spawned. or at least player pawn shouldn’t be at (0, 0, 0). If it didn’t, it should despawn the level and kill itself. But I see the level, and door isn’t there. It means FinishSpawn didn’t even called. Then what, SpawnedLevel isn’t visible, although I can clearly see the level there…? I don’t get it.

I realized quality of my code is absolutely abysmal and it’s a shame to share. But it should work. It DOES work… in editor. Now, I guess this problem can be diagnosed by checking some properties with logging, but the game eats loggers and does nothing. See all the loggers? Every single of them doesn’t do anything. Not just because it didn’t reached, some of them straight up logs string literal at BeginPlay and even that does nothing.

I tried to update project version to 4.25, but oops, I’m using Windows 7. And I heard of UE downloaded from Epic Launcher could have some bad things going on, but I didn’t investigated into it since I didn’t think it was source of the problem I’m having. Also I’ve heard game packaged with build configuration Debug can be debugged using Unreal Editor, so I tried to package my project with it but the only thing I got is big red letter saying “Targets cannot be built in the Debug configuration with this engine distribution.”. Two of them. With “Unknown Error”. WHAT THE F**K DOES THAT EVEN MEAN???

I didn’t expect the ecstasy of finally putting on end to my ever-going project to turn into such nightmare. I feel like I’m losing everything. I’m already too late and this thing is driving me insane. I am preparing this portfolio for my first-ever job as a game programmer, but… honestly, after this many things happened, I don’t even want to use Unreal Engine anymore. I don’t even want to get the job.

Unfortunately as you are finding out, code rarely behaves exactly the same way outside editor which is why you should package and test as often as possible (or as is reasonable). First of all, I would check your project settings and make sure that the game startup level is set to the level you expect. You can find that under Project Settings->Maps and Modes.

No logging takes place in shipping builds. If you want to debug, you need to package a debug build. Nothing should prevent you from packaging that from the launcher engine, unless 4.25 changed things significantly.

As far as debugging goes, there should be no issues installing UE4 from the launcher. Just make sure you also download the debugging symbols, as you won’t get far without them. You can debug in editor by launching “DebugGame Editor” from visual studio, or you can debug a packaged project by first cooking (packaging), then launching “DebugGame”. You will also need to make sure “Include Debug Files” is checked when packaging.