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.
How does TextureRenderTarget2D get TArray<uint8> type data?
Why does the REMOVE method of map container remove elements have memory leaks?
How to delete some elements correctly when deleting an array loop?
How do I set a material as a post-processing material?
UMG RichText not appear image when packaged
What is the cause of the packaging error falling back to 'GameUserSettings' in ue5?
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 |