Blueprint Runtime Error: "Attempted to access index 0 from array GameDate of length 0!

Hello

I keep getting this error within my script and I have no clue what it wants from me. I am attaching a screenshot from the engine . I am following the 3 Prong Gaming RTS tutorial!
I appreciate all your help

1 Like

It means that the Game Date array is empty when the Return Node tries to get something from it.

You have to be careful with that, though. If you implement that check, you will get no errors or warnings, but that’s not the result you need. What you need is your blueprints to do what you want them to do, and not just not give you any errors. When you see that the array is empty, you have to find out why. You have to add an element to the array somewhere, either manually or in a blueprint at runtime.


A screenshot of the blueprint that calls the Get Day function might be helpful.

You can’t get item at index 0 from an array that has no items.
To stop this error from happening, (edit: and to prevent yourself from running code on nothing) do the following any time you are working with an array:

Array → get length of array → if length is more than 0 → do code

Edit: This makes sure you never try to access something from an array that has no members. Now, your actual problem is that the array is empty in the first place and you need to look into whatever code that adds objects to the array.

1 Like

Agreed, updated answer to be a bit more clarifying.

I have checked everything and I had a Branch with a boolean that was not supplying the correct information. I had to check all my blueprints in the whole game but it was fixed :)! Thanks for the help guys!