Removing multiple instances which are referenced by their index

Hey, I have a problem which is almost funny because it’s not really a bug but to find a solution for this is like solving an impossible puzzle :wink:

I have one Instanced Static Mesh Component. And I have let’s say 3 instances I want to remove. So it’s an integer array with 3 integers, the indexes to the instances. Now I call “Remove Instance” in the loop and the index is the first, second or third number out of the array.

Now the problem is: The only way to reference an instance is with the index. But after I called “Remove Instance” once, all the instances which had a higher index than the instance I removed will reduce their index by one! So the index reference to the other 2 instances I want to remove in this array is completely worthless because they could reference any instance instead of the instance I originally meant.

I need this because I do a multi sphere trace and I want to remove all instances this trace hits. I do a For Each loop on the Hit Result Array of the Trace, and every hit result has the index of the instance which was hit, but after removing one of them the reference to all the others are just trash. I would have to do a new trace after removing an instance to get the new index. This is surely not the way it is supposed to work.

So, do you have a solution for this puzzle?