When an array is passed into a BP custom event, the array's data is passed to the event rather than a pointer to the array itself. This means edits made directly from the event node's input pin (such as adding an element to the array) do not affect the original array. Checking the box for "Pass by Reference" does not affect this behavior. This is inconsistent with how arrays are read in C++ and BP functions where editing the array affects the array everywhere.
Workaround:
Using a function instead of custom event allows edits using the input pin to affect the original array.
Result:
The length of the array is first printed in red and shows three elements, then is printed again in blue still showing three elements.
Expected:
Three gets printed in red followed by four being printed in blue to indicate the addition to the array.
Head over to the existing Questions & Answers thread and let us know what's up.
12 |
Component | UE - Gameplay - Blueprint |
---|---|
Affects Versions | 4.13.1 |
Created | Oct 12, 2016 |
---|---|
Resolved | Aug 18, 2021 |
Updated | Aug 18, 2021 |