# Getting Actor Variables From An Array?

**URL:** <https://forums.unrealengine.com/t/getting-actor-variables-from-an-array/438432>\
**Category:** Editor Scripting\
**Tags:** arrays, variables, unreal-engine, question\
**Created:** [November 27, 2018, 7:29pm UTC](https://forums.unrealengine.com/t/getting-actor-variables-from-an-array/438432 "2018-11-27T19:29:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_b5891cd6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b5891cd6](https://forums.unrealengine.com/u/anonymous_user_b5891cd6)\
**Post date:** [November 27, 2018, 7:29pm UTC](https://forums.unrealengine.com/t/getting-actor-variables-from-an-array/438432/1 "2018-11-27T19:29:57Z")

</div>

Hello all,  
I’m having a problem getting variable information from an array of actors. I want to add items into an array and pull up information from those items later. The problem is that when I try to get any of the actor’s variables it says the variable is not in scope. I thought maybe because I needed to cast the item in the array, but it just keeps failing the cast.

 ![260655-additem.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/8/eb8305045320d0f2f8dcd28f1a19f2f614ef64e6.png)

The strange thing is that if I look at the line coming off the first GET node it shows what actor is being referenced, but the item info is not in scope. Also, at the second GET node it will only print the item name if it’s the first item I pick up. Even though I’m referencing the same item in the array, I can’t get it to print the name on successive item pickups.

---

<div class="post-metadata">

**Author:** ![Detilium](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/detilium/32/985007_2.png) [@Detilium](https://forums.unrealengine.com/u/Detilium)\
**Post date:** [November 27, 2018, 7:41pm UTC](https://forums.unrealengine.com/t/getting-actor-variables-from-an-array/438432/2 "2018-11-27T19:41:13Z")

</div>

I’m not sure what you wish ti print in the first `PrintText` but if you wish the print the name of the item you just added to your inventory, you’ll need to get the item from the inventory using the index returned by the `Add` method. Here’s an example:

 ![260656-tmp4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/2/a/f2a09f84a5c3fdf1b7b2f701c37ac22c790bc198.png)

I might have misunderstood your question. If so, please let me know, but I do hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![Nebula\_Games\_Inc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nebula\_Games\_Inc](https://forums.unrealengine.com/u/Nebula_Games_Inc)\
**Post date:** [November 27, 2018, 8:11pm UTC](https://forums.unrealengine.com/t/getting-actor-variables-from-an-array/438432/3 "2018-11-27T20:11:49Z")

</div>

Agreed, right now your current set up will only ever return the “0” index of the array which will always be the very first item you pick up…ALWAYS.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b5891cd6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b5891cd6](https://forums.unrealengine.com/u/anonymous_user_b5891cd6)\
**Post date:** [November 27, 2018, 8:17pm UTC](https://forums.unrealengine.com/t/getting-actor-variables-from-an-array/438432/4 "2018-11-27T20:17:44Z")

</div>

I know that I can get the name of whatever I just put into the array, but if I want to get any information about the item after that, the variables are not in scope anymore. Say I pick up my first item. I can look at any information about that item right there. When I pick up my second item I want to see if the two items have the same name. The problem is I can no longer access the information of the first item. Even though when debugging I can see that the correct item shows up off the GET node, when I ‘getItemInfo’ it’s no longer in scope.

---

<div class="post-metadata">

**Author:** ![Detilium](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/detilium/32/985007_2.png) [@Detilium](https://forums.unrealengine.com/u/Detilium)\
**Post date:** [November 27, 2018, 8:38pm UTC](https://forums.unrealengine.com/t/getting-actor-variables-from-an-array/438432/5 "2018-11-27T20:38:45Z")

</div>

Ah, I did misunderstand your question then. I just tried replicating your issue, but it works fine for me? Could you show us the details of the actors from the world outliner? The one that’s already in the inventory, and the new one your adding?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b5891cd6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b5891cd6](https://forums.unrealengine.com/u/anonymous_user_b5891cd6)\
**Post date:** [November 27, 2018, 9:04pm UTC](https://forums.unrealengine.com/t/getting-actor-variables-from-an-array/438432/6 "2018-11-27T21:04:15Z")

</div>

I’m not sure I understand what it is your asking for. Here’s a pic of my potions within the level and their info from the world outliner. I’ve also attached a pic of the overlap event with my character. I should note that it’s the blueprint of a masteritem and that I have child classes for the health/mana potions. Maybe it has something to do with the way I set up the class structure?

 ![260657-levelpotions.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/8/4/b84d8d17c02866bea875120802ffec2177cbf480.jpeg)

 ![260658-masteritem.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/5/2/25276d6951f0ad01a5b1d16d3020734bd3964ab8.png)
