Get array element by ref example

Hi,
I’ve noticed that in the new 4.16 version of UE there is 2 get nodes of array. One is as a copy and the other is as a reference. Could anyone please show me an example how to use the functionality that comes with get by ref.

Here is a screenshot that makes things more easy to explain what I’m needing:

Thanks

The difference as far as I know, is that in the ‘copy’ node, if you apply any changes to the corresponding element, it won’t affect the element inside the array, while if you use the ‘reference’ node, any changes you apply to the element, will affect the original element inside the array as well.

Regards.

I get that, but I need a concrete example, where this is used - screenshot would be nice :slight_smile:
I don’t know how to set up the nodes so I use this functionality. I know the theory behind it.

I don’t have 4.16 installed, but this link should help you. Actually ‘get by ref’ was a feature request.

Regards

OK, so by what I gather from this is that this get by reference is only usefull if I have a struct that has an array in it?
I can see how this would speed up a pipeline, but is there any other use for it? :slight_smile:

What if I have single variable in my struct? It is somewhat cluncky to deal with the whole break the struct, then make a struct and reattach all of the variables that need to be the same, and just do some operations on that one variable that you want to change.

If i want to match functionality of older UE versions, which of these two options i should choose? I am watching older tutorial where older version is used and i have no clue.
Thanks

According to: https://answers.unrealengine.com/questions/667140/get-a-ref-not-working-on-array-of-components-quali.html

You don’t get a copy of the object, but rather a copy of the pointer which references the original. The node’s descriptor is therefore misleading but accurate.

Unreal will automatically use the ‘Get (a copy)’ node when trying to use ‘ref’ node anyway.

Essentially, the array is storing pointers to the object and not the objects themselves. This way, the array is not modified itself (in other words, what it means is you can’t change what the pointer is pointing to, but can modify the object in reference as normally).

If that was confusing; you can pretty much ignore the ‘Get (by ref)’ node and go with the copy version.
[1]: 216887-copy-ref.png

2 Likes

This should be upgraded to an answer. This is exactly what I needed to know. Thanks!

1 Like