Trouble with reindexing instances after removing some


I’m trying to add instances around the character player and destruct them when they are too far away.

  • The problem:

The destruction works fine the first time, but once the playerchar move again (and despite that the destruction loop is not triggered), it destroys more instances. It looks like there is as much secondary destructed meshes as the first time, as if it was a trouble with the reallocation of the index.
I know that removing instances shrinks the array, but does it explain the subsequent disparitions?

  • The setup:

I’m using a double loop to add instances around by comparing is current and previous location. It checks if there is not already an instance at this location and spawn it.
However, to remove instances I have an array who stacks the transformation of each instance. This array is connected to a reverseforeachloop and on key input, if the location transform is too far away from the PlayerChar, the corresponding index item of the instance mesh is removed.
The TransformationArray is cleared at each loop and refilled with instanced mesh infos so I’m sure there is no twist between them.

This blueprint is just a test and i could live without solving it but still it bugs me to not understand what doesn’t works here.

With apologies for my english and many thanks for any help.