Difference between get (a ref) and get (a copy)

What is the significant difference between using “get (a ref)” and “get (a copy)” nodes?
Especially in the context of this example:

Is there a performance difference or something else?

2 Likes

A copy is just that, a copy. But if you use get ref, any modifications you make will be written to the original.

In the first example, you don’t need to re-make the item and write it back. If you update any of the broken-out fields, that will be written back to the array element.

3 Likes

Thank you so much! Round pins in Break out node always confused me and i’ve never tried using Set By-Ref for variables inside before. But this is what I need!

Also check out the SetMembers node ( drag a pin off a structure to get it ).

That’s about right, and what we’d expect, from the name and tooltip, but I’ve read Get a Copy only makes a copy for reading primitives (float, int, bool, etc.), but not so for objects.

Blueprints stores objects in arrays by pointer - like, an array of BP_BigHeavyObject will actually have pointers to those objects - and Blueprints will only get you the dereferenced pointers, so any changes made will be to what was pointed at, that is, the original object.

So - if you use Get a Ref for an object in an array, Blueprints will change this to Get a Copy (with a misleading tooltip), but you are actually accessing the original object, not a copy.

5 Likes

If You use get a (copy) then the items will not be added in this example and if you used a ref a (copy) it will add items in that like given below is an array of structure of actors array test it like that and you will find the difference.

Are they they same speed to do operations on? I have a situation where I am reading from arrays, but not altering them, and writing to a new array (with new data, not same data).

If they are the same speed, I would then assume it is better to use “ref” to avoid duplicating memory usage?

i imagine Ref would be faster but not enough to even think about, just do what suits your code better