x

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 Arrays return data when Out-of-Bounds

Hello!

It's come to my attention that blueprint arrays can be supplied an index that will take them out of bounds. A warning is thrown as expected, but it also has some nasty behavior where it will still return valid data from the array.

Given a five element array of objects, if I attempt to retrieve element #10, it will still return element 5 - this could result in things going horribly wrong using something like complex iteration.

The array needs to return null, not an object, and the game should throw an 'accessed none' error much like UnrealScript would, before attempting to continue.

Product Version: Not Selected
Tags:
more ▼

asked Mar 11 '14 at 01:56 AM in Bug Reports

avatar image

ue4-archive ♦♦ STAFF
49.8k 3656 1981 9108

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 01:56 AM
 "Given a five element array of objects, if I attempt to retrieve
 element #10, it will still return element 5"

I agree with Luke,

This could be so very very confusing in a complex blueprint and really hard to debug, since sometimes element 5 results would be correct.... but not if trying to access element 10

I am quite curious, how can blueprints be made to throw exceptions or in some way provide unavoidable feedback to blueprint developers, and stop behavior that would be disastrous in C++ ?

Thank you for UE4!

Rama

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Hello,

Thank you for your report. We were not able to investigate this on the engine version you reported, but there have been many version changes to UE4 since this question was first posted. With a new version of the Engine comes new fixes and it is possible that this issue has changed or may no longer occur. Due to timetable of when this issue was first posted, we are marking this post as resolved for tracking purposes.

If you are still experiencing the issue you reported in the current engine version, then please respond to this message with additional information and we will investigate as soon as possible. If you are experiencing a similar, but different issue at this time, please submit a new report for it.

Thank you.

more ▼

answered Oct 03 '14 at 02:57 PM

(comments are locked)
10|2000 characters needed characters left

Hey Luke,

Thanks for your feedback. We have been unable to reproduce an array returning the last element in the array when attempting to retrieve an element beyond the array's bounds. Are you using any custom script in your project? If you will provide me with a screenshot of a blueprint with which this issue occurs, I can investigate further.

Best,

Ben Halliday

more ▼

answered Mar 11 '14 at 01:56 AM

avatar image

ue4-archive ♦♦ STAFF
49.8k 3656 1981 9108

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 01:56 AM

Hi Ben,

I'm not using anything custom in this. Here's a sample blueprint setup that I used to demonstrate the issue: alt text

It output the following in the log

 LogBlueprintUserMessages: Build Array using For Loop
 LogBlueprintUserMessages: Found Item SMBlueprint12 at index 
 LogBlueprintUserMessages: Found Item SMBlueprint13 at index 
 LogBlueprintUserMessages: Found Item SMBlueprint14 at index 
 LogBlueprintUserMessages: Found Item SMBlueprint15 at index 
 LogBlueprintUserMessages: Found Item SMBlueprint16 at index 
 LogBlueprintUserMessages: Return Array using For Loop
 LogBlueprintUserMessages: Found Item SMBlueprint12 at index 0
 LogBlueprintUserMessages: Found Item SMBlueprint13 at index 1
 LogBlueprintUserMessages: Found Item SMBlueprint14 at index 2
 LogBlueprintUserMessages: Found Item SMBlueprint15 at index 3
 LogBlueprintUserMessages: Found Item SMBlueprint16 at index 4
 LogArray:Warning: Attempted to get an item from array MeshArray1 out of bounds [5/4]!
 LogBlueprintUserMessages: Found Item SMBlueprint16 at index 5
 LogBlueprintUserMessages: Return Array using For Each
 LogBlueprintUserMessages: Appended Item SMBlueprint12 at index 0
 LogBlueprintUserMessages: Appended Item SMBlueprint13 at index 1
 LogBlueprintUserMessages: Appended Item SMBlueprint14 at index 2
 LogBlueprintUserMessages: Appended Item SMBlueprint15 at index 3
 LogBlueprintUserMessages: Appended Item SMBlueprint16 at index 4


arraybp.jpg (328.2 kB)
avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 01:56 AM

Hey Luke,

It seems that the ForLoop node is causing the issue you're experiencing. In all other cases that I've tested, a 0 or 'none' is returned when asking for an out of bounds index. I've entered a report for the inconsistency represented here.

Thanks for the feedback! If you spot any other areas where this happens (in this case it was the ForLoop macro), please let us know and we'll add it to the report.

Best,

Ben Halliday

avatar image mamoniem Apr 20 '14 at 03:06 PM

It happens but will just give a warning. If you want to reproduce it, try using ArrayLength & not using ArrayLastIndex :)

(comments are locked)
10|2000 characters needed characters left
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