I was wondering, is there any way to add an actor to a data layer at runtime? There’s no node in BP so I’ll go fishing through the source code in a bit, however, there’s a node that does this for the old Actor layer system, so I’m wondering if this is just a missing node in BP or an actual feature.
The problem comes when spawning actors. If you load and unload Data layers to control content, the spawned actors will not be assigned to any data layer so will always be loaded. If you set the actor’s “Owner” on spawn, then it will be assigned to its parent’s data layers (not checked the source on this so can’t be 100%, but from some testing that’s what I found). However, this doesn’t work for attached actors. If actor B is attached to actor A, if actor A’s data layer is unloaded, actor B will still persist in the world.
One way I thought of to get around this is to have a Dummy actor ( that is not spatially loaded) in every data layer, so when you spawn an actor you can set the data layer’s dummy as the spawned actor’s owner, so it is assigned to the correct data layer (I think). But it would be nice to have an option in the World’s settings that automatically assigns a data layer to spawned actors. Anyway, back to the initial question, has anyone found a better way to assign data layers to actors at runtime?