Keep Simulation Changes is missing various changes

I made an actor that allows me to fly through level, throw physics objects around in piles, then automatically convert them to instanced static mesh components and in theory, save them.

However, “Keep Simulation Changes” does not appear to keep the instanced static mesh components that get created (using the “Add Instanced Static Mesh Component” node) - they appear to get thrown away on exiting PIE. I tried to store a reference to the created ISMCs in an exposed array to force them to stay, but it causes a crash (which I reported via the crash reporter with a repro).

I worked around it by just adding a whole heap of InstancedStaticMeshComponents to the compiled actor, and filling those out with instances (not optimal but it works). The instances get stored, but then the static mesh asset assigned to each ISMC does not get saved with “Keep Simulation Changes” either…

So I also worked around that by adding a Call-in-Editor “Fixup” function that goes through the ISMCs and re-assigns the static mesh assets to each (I store the assets in a separate array when I fill out the instances, then I run the Fixup function in the editor after Keeping Simulation Changes). I also use the fixup function to delete the ISMCs I added for the first workaround that weren’t needed.

So it kinda works but could obviously be a lot better. The workaround means I can’t easily add more instances to an existing actor, for example.

You can repro these issues in 4.18:

Repro ISMCs not being kept:

  1. Create an actor that automatically creates several ISMCs using the “Add Instanced Static Mesh Component” node.**
  2. Run PIE, select the actor that has the ISMCs in Outliner and “Keep Simulation Changes”.
  3. Exit PIE & note the instances aren’t there.

Repro ISMCs static mesh change not being kept:

  1. Create an actor with an ISMC - assign a cube mesh and make a couple of instances and verify they are there when you place the actor.
  2. On beginplay, change the static mesh asset to a sphere using the “Set Static Mesh” node on the ISMC.
  3. Run PIE, select the actor that has the ISMCs in Outliner and “Keep Simulation Changes”.
  4. Exit PIE & note the instances are still cubes.

**if you also want to reproduce the crash, then also add the created ISMCs to an exposed array as you create them. It will crash when you exit PIE after keeping simulation changes.

Note this is blueprint only.

I discovered that my workaround isn’t really suitable - even though I add instances to several ISMCs in PIE, “Keep Simulation Changes” is for some reason only keeping the instances that got added to the first ISMC and the rest get discarded when I go back to the editor…

So I am working around it in a different way… completely forgetting about trying to add instances in PIE - I just store the transforms and meshes of all my thrown physics actors in a big array instead (Keep Simulation Changes has no problem with that). Then when I run my Call-in-Editor “Fixup” function after going back to the editor, it just goes through that array and creates all the instances then. That works, and also means I can add more instances to it afterward easily too.

However, instances added via the “Add Instanced Static Mesh Component” node remain hidden - they don’t show up as an editable component, so I’ll never be able to tweak or delete them in the editor. I might be able to add some functionality so I can manipulate individual instances in PIE by temporarily making them simulate physics again… yet to find out if that’s possible.