Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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


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 helpalt text

alt text

Product Version: UE 4.20
screenshot-9.jpg (205.3 kB)
screenshot-1.jpg (52.4 kB)
more ▼

asked Dec 06 '18 at 01:33 PM in Blueprint Scripting

avatar image

8 1 2

avatar image Tuerer Dec 06 '18 at 02:12 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Dec 06 '18 at 02:24 PM

avatar image

275 1 7 5

avatar image Tuerer Dec 06 '18 at 02:54 PM

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.

avatar image Weibye Dec 07 '18 at 09:49 AM

Agreed, updated answer to be a bit more clarifying.

avatar image BIG BIZNIS Dec 07 '18 at 11:13 AM

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!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question