Certain InstancedStaticMeshComponent instances don't render in the correct place when I add and remove instances in realtime?
So this is a very strange bug I'm running into, and would ideally like to find a workaround for in the meantime while it gets fixed in the engine, and would like to provide whatever is necessary to help.
I have an InstancedStaticMeshComponent (ISMC) that I'm adding and removing instances to/from while the game is running based on player input. The problem is, is whenever I remove certain instances, other instances will be rendered at the wrong location.
The most trivial example is as follows, with the returned indexes in brackets: I will add the first instance , then the second instance , then the third instance  I will then attempt to remove the first instance  When I do, the third instance  starts rendering at the position of the second instance .
This is 100% reproducible and doing the same adding/removing sequence always causes the same instance so be rendered in the wrong location at the same points in the sequence.
EXCEPT: If I open the game as a standalone process, the misrendering of instances will change drastically, and instances are not rendered in the wrong places (to my knowledge), they are not rendered at all and only one instance is ever rendered at a time.
FINALLY: If I'm in the editor, I can solve the issue temporarily by going into the ISMC manually and either checking OR unchecking "Use Dynamic Instance Buffer". It does not matter which it is set on before, or by default, simply toggling it causes the instances to render properly in the editor until I add or remove instances again.
Some other notes:
I'm happy to provide more information, my source in a minimized project, a video, whatever would be helpful, just let me know.
EDIT More information and testing:
Fixed in 4.19
answered Nov 15 '18 at 09:28 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here