The game I’m working on is, basically, a top-down city-building style of game. We have a bunch of static meshes that have been placed down using the Foliage tool in the editor. I have to find a way to remove some of that foliage.
Currently I have this working by iterating through the components inside the AInstancedFoliageActor, modifying the PerInstanceSMData to remove transforms and then rebuilding the physics state.
This works fine during the game - but when you close the game, it crashes during garbage collection because other parts of the engine actually refer to the indices of the original PerInstanceSMData - which I caused to go away.
Since the AInstancedFoliageActor is automatically created, pretty much all of my options (apart from not using the foliage system which, well, could possibly be more work!) require modifying that actor.
It seems like my options here are limited to two possibilities:
- Modify the engine itself so that I can modify the AInstancedFoliageActor
- Find some way to know when the game is about the shutdown and restore the properties before the actor gets cleaned up.
Number 2 seems more of a hack but I don’t particularly want to modify the engine if I can avoid it - it seems like modifying an actor, even it it’s created by the editor, should be possible.
I’m still investigating but figured that maybe somebody might have a suggestion or two for me?