I keep getting several instances of this same error. Can someone explain what this error means and how to get rid of it? I can’t seem to find any info on it.
Are you using Get node with Array Length as input? Use Array Last Index instead. Arrays are always 0-based indexed.
You are trying to obtain an array element that does not exist. Make sure you are counting your items correctly - arrays start at 0. So array [5] has elements at indexes 0, 1, 2, 3 and 4. But index 5 does not even exist. That would be out of bounds [5/4]!
Edit: We posted at the same moment, but yeah, what Gleb Black said is good practice.
That’s the thing. I am NOT trying to access an item that doesn’t exist. My array has 75 indexes (0-74).
This is the set up I used for each one. (And for some reason, all of them work except this one).
Do you pop out an element at some point? Like the standard insert new element on the 0th index - delete the last element routine?
Can’t the size of the array change at some point or another? The Arrays can be resized dynamically, so nothing guarantees the size of an array was not changed in run-time.
The best practice is still to get the last element using LastIndex. There’s also Is Valid Index node can be of some help.
Ok, let me explain exactly what my array is used for. My game has collectible items (currently 75 in total). Each collectible has been assigned a fixed number, which is represented by the index number in this array. If an item is obtained, “1” is added to the assigned index. (I.E. Mics are assigned to index 74. I had 4 mics, I obtained 1 more. Index 74 (mics’ index) is now 5). The indexes never change order, nor are they ever removed from the array. I did it this way because the items are used for crafting, and at any point in the game, the player can open the inventory/crafting window to view what they have and still need to obtain. Therefore, it dos not make any sense why my array is not reading the last index at all, or that it is stating it is out of bounds.
Also, this warning occurs ONLY when I open the inventory/crafting screen. However, throughout the entire game, the last index is not registering.
According to the log the array has 73 items, you may need to debug it step by step, printing it’s length along the way.