array get (a copy) is reference actually ??

I’m back to UE after some break. Previously I remember you could use “get (a copy)” or “get (a ref)” nodes when working with arrays to get a copy or reference to an object.

Right now I’m confused. When working with array of ints I can get a ref or a copy and they work as intended.

However, when I have an array of objects I can only use “get (a copy)”. When I try to use “get (a ref)” it gets automatically converted to “get (a copy)”. Moreover, it works like gettting a reference, NOT a copy.

Here’s an example BP of a barrel:

In it I add self to an array, change an int and print the value from the object in the array. Since I’m working with a copy (supposedly), the value of object in the array should not change. But it does and in fact prints 25, instead of 0.

The get is “get (a copy)” node:

My questions are:

  1. why can’t I use “get (a ref)” node?
  2. why does “get (a copy)” node modify the original object, as if it was a reference?

Right click the get node and you can switch it to get by ref at the bottom

Thanks. For me this option is disabled though:

I think you are already returning by ref. The option becomes greyed out once you enable return by ref.

Objects will always be passed around by reference in blueprints

As far as I know there is no way to duplicate an object in blueprints only, you’d have to do that through C++

But it’s not super common to want to duplicate objects, so maybe you should look over your approach once more and see if there is a more conventional way of doing what you want to do