# How to get a reference from an array? (not a copy)

**URL:** <https://forums.unrealengine.com/t/how-to-get-a-reference-from-an-array-not-a-copy/779040>\
**Category:** International\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [February 26, 2023, 5:01pm UTC](https://forums.unrealengine.com/t/how-to-get-a-reference-from-an-array-not-a-copy/779040 "2023-02-26T17:01:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![leofucci](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@leofucci](https://forums.unrealengine.com/u/leofucci)\
**Post date:** [February 26, 2023, 5:01pm UTC](https://forums.unrealengine.com/t/how-to-get-a-reference-from-an-array-not-a-copy/779040/1 "2023-02-26T17:01:54Z")

</div>

This seems a very basic and stupid question, I just loaded an array with instances, and now I need to perform very simple operations, like get the first one, or get a specific index from the array.

The only array functions I can see here are quite… fun (lack of a better word).

The GET returns a copy, I need the actual reference, not the copy.  
The random instead returns the reference, but I don’t get the exact value I want.

Is there a way to do a “Get” and it returns the reference? Looks like a very basic feature that most of the cases should use IMHO.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/f/5/2f56938968b39d6ab2bc3f0275a597a8a4e9a7a7.png)

---

<div class="post-metadata">

**Author:** ![RecourseDesign](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/recoursedesign/32/1194503_2.png) [@RecourseDesign](https://forums.unrealengine.com/u/RecourseDesign)\
**Post date:** [February 26, 2023, 5:13pm UTC](https://forums.unrealengine.com/t/how-to-get-a-reference-from-an-array-not-a-copy/779040/2 "2023-02-26T17:13:44Z")

</div>

Hi leofucci,

For things like Instances, the array will contain pointers to those instances rather than the whole class itself.

Passing a Reference to a Pointer is a bit redundant - that’s why for things like that you don’t see the “Get (ref)” node like you do for actual values.

---

<div class="post-metadata">

**Author:** ![leofucci](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@leofucci](https://forums.unrealengine.com/u/leofucci)\
**Post date:** [February 26, 2023, 5:39pm UTC](https://forums.unrealengine.com/t/how-to-get-a-reference-from-an-array-not-a-copy/779040/3 "2023-02-26T17:39:56Z")

</div>

Ok, how do I get a Pointer on index 9 instead of a copy of the instance? if that question suits you better.

---

<div class="post-metadata">

**Author:** ![umutfaruk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@umutfaruk](https://forums.unrealengine.com/u/umutfaruk)\
**Post date:** [February 26, 2023, 5:47pm UTC](https://forums.unrealengine.com/t/how-to-get-a-reference-from-an-array-not-a-copy/779040/4 "2023-02-26T17:47:06Z")

</div>

use “Get a ref” for this

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/1/b/f1b38e1a132a9504d7fbddb6c54df0fa4ad88455.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/c/5/9c55bd1499fdb6ce3f86376e6ce94e4f92be2697.png)

---

<div class="post-metadata">

**Author:** ![RecourseDesign](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/recoursedesign/32/1194503_2.png) [@RecourseDesign](https://forums.unrealengine.com/u/RecourseDesign)\
**Post date:** [February 26, 2023, 6:03pm UTC](https://forums.unrealengine.com/t/how-to-get-a-reference-from-an-array-not-a-copy/779040/5 "2023-02-26T18:03:57Z")

</div>

index 9 will be a pointer, not a copy of the instance - the array “Get” will return a copy of the arrays pointer, but that pointer still points to the original instance , in the test below note that both the second read from the array and the actual object return the updated value:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/c/d/5cd07727d531d7918bd682092a6a1419e3279dde.png)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/7/7/5773655890444809f34274905e9e00c076dfcbf0.jpeg)  
(0 is the first value, logging goes upwards)

---

<div class="post-metadata">

**Author:** ![RecourseDesign](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/recoursedesign/32/1194503_2.png) [@RecourseDesign](https://forums.unrealengine.com/u/RecourseDesign)\
**Post date:** [February 26, 2023, 6:48pm UTC](https://forums.unrealengine.com/t/how-to-get-a-reference-from-an-array-not-a-copy/779040/8 "2023-02-26T18:48:09Z")

</div>

> [@No Get Ref for actor subclass array?](https://forums.unrealengine.com/t/no-get-ref-for-actor-subclass-array/99187):
>
> Hey. When i take an array variable set to use a actor subclass, and I drag out of it I only see get a copy instead of get a ref for an input index. Why is this? Is there any way to get a reference instead of a copy?

---

<div class="post-metadata">

**Author:** ![leofucci](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@leofucci](https://forums.unrealengine.com/u/leofucci)\
**Post date:** [February 26, 2023, 6:53pm UTC](https://forums.unrealengine.com/t/how-to-get-a-reference-from-an-array-not-a-copy/779040/9 "2023-02-26T18:53:21Z")

</div>

I thought this would be the solution, but as soon you select that option, it gives you this warning, and automatically changes to the Get(a copy)

I’m using latest version available at the moment, if you have latest installed, you should see the same.

🤨

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/c/d/ecdba73a642afb88b219f727d763b6fff7474988.png)

---

<div class="post-metadata">

**Author:** ![leofucci](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@leofucci](https://forums.unrealengine.com/u/leofucci)\
**Post date:** [February 26, 2023, 6:55pm UTC](https://forums.unrealengine.com/t/how-to-get-a-reference-from-an-array-not-a-copy/779040/10 "2023-02-26T18:55:49Z")

</div>

Oh man, the post there says

> “For objects you always get a reference, the tooltip of Get here is misleading. Despite the returned object being a “copy” only, changes made to this item will be propagated back to the array.”

I need to check but is a big deal such a misleading message, to have a copy in server/client games would make a huge difference, need to try it out but it seems to be the answer.
