Hi, this is my first question here in this forum, so sorry if it’s not the best place to ask this. First of all, thanks for your time.
I’m making a game with procedurally generated levels. To sum up, I have an actor that generates the dungeon layout, and instances other actors that are the rooms and corridors themselves. Then, inside those rooms and corridors, other things like torches, stairs, ladders, etc. are instanced.
Everything inside the rooms and corridors is done with ChildActorComponents, while the rooms and corridors themselves are independent actors which have their references stored in the “generator” actor.
This works perfectly in editor, allowing me to choose between generating the level in the construction script (so it’s always the same) or in the begin play (so it’s random). Everything seems to work well, and old references are destroyed when “resetting” the dungeon.
The problem comes when playing on a build. Randomly, even just after booting up the game (without ever being in the dungeon map), I get a crash like this
Ensure condition failed: !Obj->HasAnyFlags(RF_NeedLoad|RF_WasLoaded) [File:D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line:3371]
Replacing a loaded public object is not supported with cooked data: ChildActorComponent /Game/Maps/Dungeon/DungeonLevel.DungeonLevel:PersistentLevel.DungeonGeneratorBP_C_2.Room 3.Ladder 0 (Flags=0xe59f1040, InternalObjectFlags=0x20280000)
This is transcripted from a picture, so sorry if I got something wrong, but I guess the important error is the “Replacing a loaded public object is not supported with cooked data”.
The crash happens with other objects inside the rooms (instead of the “ladder” in the example) like the torches, stairs or traps, and it happens at random times, which is what is driving me insane. The levels themselves work correctly in the build, and you can even play several times getting new level layouts without a crash and get one, for example, when you get a game over (which we have implemented by making the player go to another map, so it’s not “resetting” the dungeon and shouldn’t trigger that error).
I have looked around and I didn’t see anyone with that problem, except this bug report in (coincidentally) a dungeon generator plugin.
If anyone could lead me to a hint on how to fix this I would appreciate it very much! I’ve been trying to fix this for 2 weeks and I don’t know where to look anymore.
Thank you very much!