[Critical engine bug] Workaround for being stuck at 70%,71%,72% loaded

We have had a problem where unreal locks up on load (after working in a session where everything worked), and have tracked it down. This is a serious issue because you lose all your work and have to revert back to the last time you made a backup to be able to fix anything. No log is produced in this case.

Our structure is that we have an OurGameModeCPP, with an OurGameModeBlueprint inherited from it for setting custom defaults in editor
We have a OurPlayerCharacterCPP, with an OurPlayerCharacterBlueprint inherited from it. OurPlayerCharacterBlueprint is the default pawn.

What we were finding is that if OurPlayerCharacterBlueprint (or any class that it contained a reference to) did a GetGameMode() into a Cast To OurGameModeblueprint, the editor would never load again (even if this cast was never executed). If we changed it to a Cast To OurGameModeCPP, there would be no problem.

We finally tracked down the problem to this code in the constructor of OurGameModeCPP:

    static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/Blueprints/OurPlayerCharacterBlueprint")); 
if (PlayerPawnBPClass.Class != NULL)
{
	DefaultPawnClass = PlayerPawnBPClass.Class;
}

If we removed this code there was no longer a problem, even though this is how setting a default pawn class is done in Unreal CPP (I think many of the samples do this).

If I had to guess on the bug (here’s where I lose my cred), it’s that during the process of loading, the system loads in class definitions on demand.
OurGameModeBlueprint has a reference to OurGameModeCPP which then on construction has a reference to OurPlayerCharacterBlueprint class which refers to OurGameModeBlueprint again (because it contains the cast to OurGameModeBlueprint) which isn’t identified as being loaded, so it starts the cycle again. In general this reference stuff is robust, but something about child/parent classes mixing with c++/blueprint breaks it.

Anyways, if anyone else has this problem (I see several unanswered questions about this on the forums), our workaround is to put all the blueprint functionality in c++ and then always cast to the CPP class instead of the blueprint class. This has made things robust again.

-Michael

The engine doesn’t like something in your code despite the compiler being cool with it.

You’ll have to start a commenting spree to work out what it is.

@WaspSix: The real issue is that everything runs fine until I exit and restart the editor. The other issue is that I don’t have to execute anything, I just need a reference somewhere in the blueprint to make it lock up. This implies some sort of preprocessor failure, which is worth reporting (I know they were looking for repro cases on this a while ago)

I’m unsure about that but it’s always the same for me, the moment that you place something the compiler doesn’t mind but the engine freaks out about it always loads up to 70% until the code/addition is removed but know unreal engine it’ll probably be an internal bug, do what many seem to have to do and get the source and enter the rabbits hole :stuck_out_tongue: