Weird Array issue

Hi,

I have an object array, and in a function I remove a certain element from it using the Remove node and then I print out the array elements using a for each loop (or print out the length of the array) and the references are indeed removed but the array indexes don’t update.

So if I have two object references in my array and then I remove one, and then print out the length it will still say 2, however the refernece is removed.

Why is this happening? In my understanding the array should update after using the Remove node (https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Arrays/ArrayNodes/), but apparently it doesn’t for me.

Any help would be appreciated.

Thanks.

I’m bumping this, because I still haven’t found a solution to it.

If I remove an object and print out the value of the returned bool of the Remove node (if the remove was successful), it will return true, the reference will be removed (return invalid), but the lenght of the array won’t update (not even minutes later). I have tested it with different variable types and even with the same one I’m having the issue with but I could never reproduce it.

Anyone ever experienced this? Shall I fill a bug report?

If you have 3 items in the array, and remove the second (index 1), then read the value of index 1- is the value the original second or original third object? Is the length still 3?

Also, if you can’t repro it that might just be a one time bug. I’d pack it off into a zip file to submit with the bug report if possible.

Hi, thanks for your reply!

Problem being the array with the issue has actually many elements filled up in random order, I just simplified the problem for better understanding. However, I can tell that the array indexes do not update, if the first 3 elemts of the array would have a value of 1, 2, 3, and I remove the elements at the first two indexes it would print out 0, 0, 3, saying the length of the array is 3.

You are probably right, it is most likely a one time bug, unfortunately, that array is heavily used in the game, it is referenced in almost every class, will be a nice amount of work to fix it.

Anyways, thank you for your help!

The idea of having to recreate my array made me think, and a workaround I found for anyone ever experiencing this is to use the Find node to get the index of the element that you want to remove, and use the Remove Index node instead of the Remove Item, this way the array seems to update. Weird.