Can't remove item from index

What type of array is your AllInstances? I haven’t seen a find node with 3 inputs before.

Basically what the title says. I have tried removing an item with the remove item and remove index nodes but they don’t work or better said they only work temporarily. The length of the array changes but then it goes back to normal when the for loop is called again. I read that it was a bug that happened because of me doing it in a function so I tried doing it in the main blueprint but that didn’t work either. Any ideas?

It is a structure type variable with an integer and a transform. More info on here

may not be the cause, but just for better understanding:

what exactly do you mean with “during the for loop”?

There’s a return node at the end of the loop body, so it seems it won’t do any further loop run after remove_index.

The for loop is called with the tick event. I’ll edit it now.

It’s not a good practice to call loops every tick.

maybe it helps if we could have a screenshot of where the variable “all instaces” gets set.

Are you sure it will find an element with those Block Id and Transform values?

Also it may not work correctly on Event Tick, because For loop may be going more than one tick, before it removes index.
Anyway calling loop on Event Tick may lead to unpredictable results, especially if that loop is expected to run for large number of iterations and/or process complex data. Basically there will exist multiple instances of this function, all processing same value (your array).

Try redesigning your code to not call this function every tick and then comment, if problem persists.

Could you please show us the whole Function?

Alright, turns out that this entire problem was just an illusion. I just found out two actors with the same array were being spawned in the same place perfectly on top of one another so when I called the function to remove one item from the array I would print the length from the array, remove the item, print the length again and then without realizing it I did the same with the actor which gave the illusion that it wasn’t being deleted the first time. That doesn’t mean you guys wasted your time though. All your suggestions really helped in making my code 10 times easier to read and probably more efficient. Sorry I couldn’t reply earlier but I have been without internet for the whole day.

Good thing it works now!