Fixing UE5 Actors Disappearing when Building Lighting

, updated January 7th, 2023 🔖 game-development ⏲️ 1 minute to read

In Unreal Engine 5.1.0, if you create blueprint actors which contain lights, they will disappear when you try to build static lighting under certain circumstances:

This is due to the command MAP REBUILD ALLVISIBLE being run automatically by the editor (and this command is completely broken in 5.1.0 - try running it in the console). We need to find a way to stop this command being run.

Remove Lights from Blueprints

One option is to remove lights from your blueprints and move them to separate light actors. This may be quite a big effort depending on how much content you have.

Move Blueprints In-World

Instead of defining separate blueprint assets in your Content folder, move the actors containing lights in-world, so they are all defined individually by creating an actor, then adding components to it (not saved as a blueprint). These actors are not affected by the bug, but this again may be quite a big effort depending on how many actors you have.

Build Lighting Only

One way is to build only lighting, so that MAP REBUILD ALLVISIBLE is never run:

Remove BSP

The above fix doesn't work if you have BSP in your scene because the command is still forced to run - see the code here for more information: EditorBuildUtils.cpp#L389-L407

If you get rid of all BSP in your scene, that will allow you to run "Build Lighting Only", and MAP REBUILD ALLVISIBLE will not run. Conveniently you can convert BSP to static meshes at the click of a button.

Code Workaround for BSP

Compile the engine from source and comment out the following line: EditorBuildUtils.cpp#L406. That should allow a lighting only build to work without geometry being rebuilt and the bug being triggered.

if( bBSPRebuildNeeded)
{
   // BSP export to lightmass relies on current BSP state
   // GUnrealEd->Exec( InWorld, TEXT("MAP REBUILD ALLVISIBLE") );
}

I ended up implementing this code fix and compiling the engine myself, as I needed to build lighting on a level with BSP and blueprints with light actors.

The following thread has a lot of info on this subject: https://forums.unrealengine.com/t/actors-bp-disapear-when-build-geometry-or-lighting-ue5-1-0/692183/6

🏷️ light actor blueprint bsp command fix engine code disappear bug scene editorbuildutils ue5 unreal editor

⬅️ Previous post: Fixing UE5 Level Sequence Assertion

🎲 Random post: Serverless Git LFS for Game Development

Comments

Please click here to load comments.