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.
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.
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
@3dRaven Yeah I thought so, but the tooltip’s description of the node says it’s a copy (like in my first post).
@Zeaf Thanks. Yeah I don’t need a copy, +1 to what you wrote. But I’m just confused, if it’s a reference then why is the “get (a copy)” node shown by default when you try to place it. If it’s a ref it should be “get (a ref)”…
Looks like Unreal Engine now automatically converts “get (a ref)” to “get (a copy)” for object arrays, but it still behaves like a reference in practice. You might need to adjust your logic accordingly when working with arrays of objects.