4.18 has introduced a new feature to re-arrange arrays in the editor. This works well sometimes. But I’ve found that reordering can break the array if it’s marked as Instance Editable.
Steps to reproduce the bug:
- create a new array, add a few items to it
- mark that array as instance editable
- reorder items in that array
Following this steps will turn the array into a broken state. It will show up as if it were fine and working in the editor where you just reordered the items. But in-game, if you try reading its values, you’ll find that the reordering added new items to it using their default values (or empty), these items cannot be changed, or removed. In fact, in this state, if you delete all items from the array and make it empty. Reading it in-game will still read the same items in it.
Here’s an example project that contains arrays already in the glitched state so you can see it for yourself:
This project is simply the Third Person Template. All I did was add a couple of arrays on the Character Blueprint, make instance editable, reorder, print their values on screen when you press X. You can see that the values printed are different from the values of the array in the editor. If you try to change the array in the editor, it will keep printing the wrong ones.
Here’s a screenshot from that project that shows exactly the problem:
Notice how it’s the same array on the left and on the right. On the right, the values it should have showing correctly in the editor after reordering it. But on the left, you see what are the actual values recorded internally that are being read in game. See how it has one extra element that was added at index zero, and the others were actually not reordered.
After the array is in this broken state, I have not found any way to fix it. So for my only solution is to do a git reset --hard HEAD to return to the previous commit before reordering the array. Then never reorder it again.