How to identify an 'Instanced Static Mesh'-instance by Index after 'Remove Instance'
i am having a problem with removing specific instances of a grid of instanced static meshes by a given X-Y-grid-position, because they lose their indices after using the 'Remove Instance'-Node in blueprints.
For the first remove this is fine, because all instances still have their original index, but by removing one, all other instances with a index higher than the one which has been removed seem to get their indexes decremented by 1 so that there are no empty index-numbers in the array.
So if i remove the instance with the index 0, the prior instance with index 1 gets index 0 and so on. This is a problem for me, because all instances have their fixed location in a X/Y-grid-system, but their indices aren't a key to identify any of them after all their indices got shifted.
For Example this is a 3x3 grid of instances represented by their index:
2 5 8
if i remove the instances with index 0 (X:0, Y:0), 4 (X:1, Y:1) and 6 (X:2, Y:0) it looks like this:
1 3 5
small x indicates where an instance has been removed.
So if i now want to remove instance at X:1 Y:2, it's very hard to reconstruct which index it has. I have to calculate how many instances have been removed before and after every instance to guess their new index.
Because indices are supposed to identify something it seems not logical to me, that the instances get their indices changed. Am i misunderstanding how the indices work and how to access them correctly or is there any workaround to find out which instance has which index after several of them have been removed?
I just have an array that runs in tandem with the instances. When I add an instance, I add an item to the array. When I delete an instance, I delete that index also from the array. The array can contain indexes, id numbers, references... whatever you need to link each instance to something else. So, if you need to get an instance for object x, you find the link to object x in the array, then the index you found will match to the instance index you're looking for.
answered Aug 02 '17 at 11:00 AM
Hi ! Just want to mention - Alex and Ian talk about this array behavior in Training Stream around 15 min. mark
answered Mar 22 '18 at 05:42 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here