Transfering attached actors between levels

In my game a player can pick up weapon attachments, that modify the gun stats and looks (silencer, longer magazine, scope, etc). The modified stats I can transfer between levels in GameInstance, so that’s not a problem. However, when I use OpenLevel, the attachments reset. The same happens with LoadStreamingLevel.

I’d also rather use OpenLevel due to how my procedural level generation works (it uses level instances, not actors, as building blocks).

I heard about SeamlessTravel and that you need to overload some function and add actors you want to transfer to an array, but it doesn’t seem to be exposed to Blueprint.

Since the stats can be saved in GameInstance, the thing I care about is the visual aspect of the weapon attachments, so any method of keeping them will do. Maybe attaching StaticMesh components to the weapon? I have no clue.

Any help will be appreciated.

One solution (and probably not the smartest one, I probably need more insight in your project) could be that every time you attach something new to your weapon, you also add it to an array/set (of actors/meshes with the transform included) within that Blueprint. So that when you load into the new level you can iterate over that array and just reattach all the attachments.

Let me know if you need more help!

Cheers!

I did try that, that is adding the attachments’ classes to an array in GameInstance, and then spawning them in the world and attaching, but for some reason it freezes the editor and makes it steadily increase memory usage, as if it was an endless loop.

I have no idea how to make it work either, since, well, there’s no way in hell a foreach loop can even be endless.