Remove Index/Item node with keep array size bool

Hello!

It would be nice if you could add a BP node with the same functionality as the Remove Index or Remove Item array nodes, except that it also has a bool for keeping the array the same size. It would be something like the opposite of Set Array Elem node, which can resize the array to fit the added index.

The problem is that if you have some functions relying upon an array’s carefully sorted indexed items, removing an item ruins that structure.

Example: I have carefully added 5 elements in this order with corresponding indices: Wind[0], Water[1], Fire[2], Earth[3]

I also have a selection system implemented and my currently selected item(which is an int) is Water[1] and my previously selected item(which is also an int) is Fire[2].

Now I want to remove Water[1] from my array and update the currently selected item to my previously selected item Fire[2], BUT because removing an item from an array all remaining index numbers will update to close the gap, I will now have Fire on index 1, instead of index 2, where I carefully placed it.

I hope someone sees this and understands the need for it. It’s pretty much the same opposite as Set Array Elem node with the “Size to fit” bool.

Thank you!

I think you misunderstand what the keep same size array boolean does. It simply ensures that if the array were to cross the threshold that the engine would want to resize the amount of allocated memory for the array, that it will not. It does not mean that the indices for the items in the array will remain the same.

It very much depends on what the types of the elements are in your array, but assuming they are objects of a form, instead of using Remove you should use Set and assign a None in to that slot to maintain your spacing.

I’m doing this but when loading the level again some unpredictable things happen, like loading the element I set to none and another element that I didn’t set to none disapears from my level, any hint?

Use set for it. Just set variable without actual data to set. It would keep array size and clear an element, so is valid would fail, if thats an object.

Plus setting any element directly is cheaper than removing and then re-adding an element.