# Blueprint "Array Get by Reference", and edit struct elements directly

**URL:** <https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841>\
**Category:** Feedback & Requests\
**Tags:** unreal-engine\
**Created:** [December 26, 2014, 11:34pm UTC](https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841 "2014-12-26T23:34:34Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 13, 2017, 3:06pm UTC](https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841/21 "2017-04-13T15:06:48Z")

</div>

> [@Dev.TMG;694716](#):
>
> \> No error/log occurs but the values set to the struct member arrays seems to be ignored.  
> Correction.  
> No error/log occurs when values are set to the struct member / member arrays (as if a struct exists),  
> but original array of structs which is connected to Get node input pin will not changed (as the struct Get node returned is not contained in the original array of structs).
> 
> Thanks.

What’s the questions here? Could you post the setup that’s giving you the headache? Admittedly, structs are a tad fiddly.

---

<div class="post-metadata">

**Author:** ![Dev.TMG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dev.TMG](https://forums.unrealengine.com/u/Dev.TMG)\
**Post date:** [April 13, 2017, 8:45pm UTC](https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841/22 "2017-04-13T20:45:38Z")

</div>

If Get returns a reference, Set also treats params as refeence is better… I think. (Get is for getting a element from arrays, but we need some Set function to store the ref Get returns.)

UE-24080

> **[The Unreal Engine Issues and Bug Tracker](https://issues.unrealengine.com/issue/UE-24080)**
>
> Welcome to the Unreal Engine Issue and Bug Tracker. You can check the status of an issue and search for existing bugs. See latest bug fixes too.

Improve Get Array Item to return by-ref instead of by-value

\>And it lacks what will happen if index is not valid.  
This part is my mis-understanding of Resize node etc behavior, sorry.  
My headache was  
1.Resize an array of struct which contain arrays as member \< I thought this does not add elements.(as step 3 seems not work.)  
2.Get an element from the array \< Can get. Can set values to arrays inside the struct after resize them.  
3.Try to use the struct in another place (Get from array of struct). \< Seems not exist. This is a mislead point.

Part of my troubles maybe depends on UE-6451.

> **[The Unreal Engine Issues and Bug Tracker](https://issues.unrealengine.com/issue/UE-6451)**
>
> Welcome to the Unreal Engine Issue and Bug Tracker. You can check the status of an issue and search for existing bugs. See latest bug fixes too.

Set Members in Struct node doesn’t work if the Struct is contained within an Array  
(will be fixed in 4.16)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 13, 2017, 10:51pm UTC](https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841/23 "2017-04-13T22:51:24Z")

</div>

> [@Dev.TMG;694952](#):
>
> If Get returns a reference, Set also treats params as refeence is better… I think. (Get is for getting a element from arrays, but we need some Set function to store the ref Get returns.)

Not sure if I follow, can you show us an example of where you have trouble setting something?

> [@Dev.TMG;694952](#):
>
> Part of my troubles maybe depends on UE-6451.
> 
> [Unreal Engine Issues and Bug Tracker (UE-6451)](https://issues.unrealengine.com/issue/UE-6451)  
> Set Members in Struct node doesn’t work if the Struct is contained within an Array  
> (will be fixed in 4.16)

This already works fine if you use SetMembersInStruct node.

Perhaps you’d want to start a new thread with a pertinent example.

---

<div class="post-metadata">

**Author:** ![Dev.TMG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dev.TMG](https://forums.unrealengine.com/u/Dev.TMG)\
**Post date:** [April 20, 2017, 1:21pm UTC](https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841/24 "2017-04-20T13:21:08Z")

</div>

\>Set also treats params as refeence is better

> [@Everynone;694983](#):
>
> Not sure if I follow, can you show us an example of where you have trouble setting something?

Maybe having a new thread is better but  
the problem is that we tend to think Set also treats arrays as refs if the input is a ref.  
(Set converts a ref to a copy, though.)

In 1st image of Zhi Kang Shao’s post, “Temp Attackable Target” is a copy of “Enemies Within Attack Range”,  
so any changes to Temp Attackable Target does not affect Enemies Within Attack Range,  
and needs to write it back with Set Array Elem.

What we want is that changes to Temp Attackable Target also changes original array (Enemies Within Attack Range).

---

<div class="post-metadata">

**Author:** ![Harcarik](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Harcarik](https://forums.unrealengine.com/u/Harcarik)\
**Post date:** [September 7, 2017, 6:52pm UTC](https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841/25 "2017-09-07T18:52:13Z")

</div>

Please forgive a noob barging in, but i have strange dilemma.  
I am following older tutorial on and in the version shown there there is just one ‘Get’ function. I am using 4.16 where i have two options (gasp). Which one should i choose to match the functionality of the tutorial, or older UE versions - ‘Get’ (a copy) or (a ref)?  
Thanks.

---

<div class="post-metadata">

**Author:** ![vb4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vb4](https://forums.unrealengine.com/u/vb4)\
**Post date:** [September 10, 2017, 10:17am UTC](https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841/26 "2017-09-10T10:17:15Z")

</div>

The distinction likely doesn’t matter if you don’t know which to use.

Basically, if you want to make changes to the variable, you’ll need a reference. A reference points to the address of the original variable, which means that any changes to it are done to the original variable.  
If you just want the variable in order to look at its content or store some temporary calculations inside of it, a copy is perfectly viable. A copy stores a copy of the value of a variable, as the name would imply. Make changes to it and the changes will only affect the copy, not the original variable.  
Read up on pointers if you want to know more about the differences.  
If you are using an old tutorial, it most likely works under the assumption that references are not possible. Meaning that the code will be intended for copied values anyway.

tl;dr  
If the tutorial is that old, go with the copy.

---

<div class="post-metadata">

**Author:** ![eobet](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eobet/32/465239_2.png) [@eobet](https://forums.unrealengine.com/u/eobet)\
**Post date:** [May 3, 2021, 8:56pm UTC](https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841/27 "2021-05-03T20:56:14Z")

</div>

> **[The Unreal Engine Issues and Bug Tracker](https://issues.unrealengine.com/issue/UE-6451)**
>
> Welcome to the Unreal Engine Issue and Bug Tracker. You can check the status of an issue and search for existing bugs. See latest bug fixes too.

This says fixed, but I couldn’t figure out how to use it. Does anyone have an example?

 ![bild](https://d3kjluh73b9h9o.cloudfront.net/original/3X/7/7/77fca4465e0f8135951fff485bd49b3a26df7d34.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 4, 2021, 5:59am UTC](https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841/28 "2021-05-04T05:59:56Z")

</div>

Ensure you Get by Ref (diamond icon):

![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/5/255fa8fee3cb54b90d4abcc8346e3415296161ea.png)

Set Members, select that node and expose what’s needed in the panel:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/6/6/66f9c551416bcf90c739ba4bc40ac01b717a53a0.png)

---

<div class="post-metadata">

**Author:** ![eobet](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eobet/32/465239_2.png) [@eobet](https://forums.unrealengine.com/u/eobet)\
**Post date:** [May 4, 2021, 10:53am UTC](https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841/29 "2021-05-04T10:53:29Z")

</div>

Thank you!

I didn’t realize the thing about the details panel.

[Previous page](https://forums.unrealengine.com/t/blueprint-array-get-by-reference-and-edit-struct-elements-directly/17841.md?page=1)
