Pack Level Actors breaks component references in BP

I’m looking for confirm some odd behavior. Is it a bug? A shortcoming? Or am I doing something very wrong?

I create a packed level actor from some actors in in Scene_A.

This results in the creation of a packed level level, Scene_B, and a packed level actor BP_Scene_B.

So far so good.

I edit the BP, BP_Scene_B and modify the ConstructionScript. In that script, I reference one of the HierarchicalInstancedStaticMesh components and do something to it. Such as change a material. I save it out.

If I go back into Scene_A and play with the instance of BP_Scene_B, I can see the material change when I make changes to the instance, as I should.

All good so far.

However, if I decide to add a new detail static mesh to Scene_B, it doesn’t automatically propogate to BP_Scene_B. However, if I go to the build menu and use “Pack Level Actors”, the system updates BP_Scene_B to contain components for the newly added static mesh. This makes sense even if the extra step seems possibly redundant.

The problem however, is that the ConstructionScript breaks. Specifically, the reference to the existing HierarchicalInstancedStaticMesh is broken. And this causes an error to be thrown upon Construction. It breaks the BP_Scene_B.

I think what’s going on, is that the original HierarchicalInstancedStaticMesh is being destroyed and recreated, without the references being updated to the new component. Indeed, if I just create a new component and substitute it, things work again. Right up until I decide to add a new mesh or some other change to Scene_B, which neccesitates the usage of the project wide “Pack Level Actors” tool again.

So, is this a bug? A shortcoming? Am I doing something wrong? Am I doing a thing that’s explicitly bad practice? Thoughts? This is in 5.1p2.

1 Like

Further information follows:

I dug into the source for the builder. A lot of relevant code can be found in the engine at:

Source\Runtime\Engine\Private\PackedLevelActor\PackedLevelActorBuilder.cpp

Anyhow, this gave me some insight into what is actually happening.

After browsing I took another look at the issue and noticed that this seems to be a naming issue.

See attached pic for ref:

So, if I keep hitting “Pack Level Actors” the names of the components keep changing between two states, due to name collisions it seems.

I leave two component reference nodes in the blueprint, one from each state, with a different name. “{component_base_name}” and “{component_base_name}2”. And now, every time I hit the “Pack Level Actors” one becomes valid and the other invalid, as the name keeps toggling between the two possibilities.

And that’s it. So presumably the build logic in the afore referenced cpp needs to make sure the components end up named as they were in the InActor, and this should be fixed.

So I’ll answer my own question and call this a bug. I’ll file it in the issues system.

Bug tracker link:

Unreal Engine Issues and Bug Tracker (UE-168469)

I debugged, found and fixed the issue.

I am committing a fix and will try a pull request.

For those that are interested the problem is:

The Build logic deletes the old InstancedStaticMesh Components from the “SimpleConstructionScript.” Subsequently it adds the newly created Components it generated from a temporary level.

However, when those new components are added, they end up colliding with the old component names. This is because the name collision is run against the BP’s “Skeleton.” And the Skeleton has not been regenerated now that the old components have been removed.

Adding a simple call to:

FKismetEditorUtilities::GenerateBlueprintSkeleton(BP,true);

after it removes the old components fixes the subsequent problems.

Pull request here for reference:

https://github.com/EpicGames/UnrealEngine/pull/9719

1 Like

Hi, I also encountered this issue in 5.1.0
I didn’t realize it is a bug. Hopefully, it gets fixed soon as the Packed Level Actors seem pretty powerful with it.