# Gameplay Tags - Item Quantities

**URL:** <https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129>\
**Category:** Programming & Scripting\
**Tags:** inventory-system, unreal-engine, Gameplay-Ability-System, UE5, question\
**Created:** [October 15, 2024, 8:37pm UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129 "2024-10-15T20:37:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![CurleeD85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CurleeD85](https://forums.unrealengine.com/u/CurleeD85)\
**Post date:** [October 15, 2024, 8:37pm UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/1 "2024-10-15T20:37:03Z")

</div>

As part of a demo I have been working on for an RPG, I have made gameplay tags for particular items needed for one of five tasks in that demo. Though I’ve made a data table for each item, I am unsure as to how to set a quantity for each item. This is so the game will know how many of each listed item the player has, and it will also be used as a condition to determine if the task is done successfully.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/4/f/c4fdcbd99e670a407e6f622877235cf32d90f77b.png)

Is it possible to add quantities to items listed as gameplay tags?

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [October 15, 2024, 10:56pm UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/2 "2024-10-15T22:56:45Z")

</div>

Hey @CurleeD85!

Kind of. You need to get their inventory as an array and then for each, if “has Tag” then add it to another array. If array LEN \> your specified number, then you have a True or false bool! 🙂  
Hope that helps!

---

<div class="post-metadata">

**Author:** ![CurleeD85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CurleeD85](https://forums.unrealengine.com/u/CurleeD85)\
**Post date:** [October 16, 2024, 12:41am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/3 "2024-10-16T00:41:59Z")

</div>

I did consider using arrays, actually. I wasn’t sure if it was the correct approach. But okay, I’ll try that. Though how do I add an array attribute to a preexisting gameplay tag?

---

<div class="post-metadata">

**Author:** ![doctorpepperdan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@doctorpepperdan](https://forums.unrealengine.com/u/doctorpepperdan)\
**Post date:** [October 16, 2024, 1:30am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/4 "2024-10-16T01:30:10Z")

</div>

Id recommend a map variable, of item object references or names, to quantities

---

<div class="post-metadata">

**Author:** ![CurleeD85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CurleeD85](https://forums.unrealengine.com/u/CurleeD85)\
**Post date:** [October 16, 2024, 1:37am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/5 "2024-10-16T01:37:01Z")

</div>

There will be a dialogue widget that will show text based on whether or not the player has the correct items and needed numbers. If I used a map variable, I wouldn’t be able to cast to it, since one can’t cast to any variables within a level BP.

---

<div class="post-metadata">

**Author:** ![doctorpepperdan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@doctorpepperdan](https://forums.unrealengine.com/u/doctorpepperdan)\
**Post date:** [October 16, 2024, 4:05am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/6 "2024-10-16T04:05:28Z")

</div>

Got it I was thinking like a map variable in an inventory system, maybe I’m not quite understanding what exactly you need

---

<div class="post-metadata">

**Author:** ![CurleeD85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CurleeD85](https://forums.unrealengine.com/u/CurleeD85)\
**Post date:** [October 16, 2024, 5:41am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/7 "2024-10-16T05:41:11Z")

</div>

In simplest terms, how do I add an array to a preexisting Gameplay Tag for the player’s inventory to give each item on the list a quantity?

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [October 16, 2024, 10:59am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/8 "2024-10-16T10:59:07Z")

</div>

you could use a Struct with variables Tag/Quantity

---

<div class="post-metadata">

**Author:** ![CurleeD85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CurleeD85](https://forums.unrealengine.com/u/CurleeD85)\
**Post date:** [October 16, 2024, 4:07pm UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/9 "2024-10-16T16:07:40Z")

</div>

Are you talking about a variable deriving from Gameplay Tag? Or integers associated with it, or…what?

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [October 17, 2024, 1:32am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/10 "2024-10-17T01:32:04Z")

</div>

a struct is a group of variables so you can add what you want

---

<div class="post-metadata">

**Author:** ![CurleeD85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CurleeD85](https://forums.unrealengine.com/u/CurleeD85)\
**Post date:** [October 17, 2024, 3:54am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/11 "2024-10-17T03:54:06Z")

</div>

So would a struct be a group of variables suitable for any and all items and equipment to be found or purchased in an RPG, as well as the quantity of each? Can you also point me to any straightforward tutorials if you know of any, please?

---

<div class="post-metadata">

**Author:** ![CurleeD85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CurleeD85](https://forums.unrealengine.com/u/CurleeD85)\
**Post date:** [October 17, 2024, 5:18am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/12 "2024-10-17T05:18:36Z")

</div>

After some feedback I’ve received, here is a struct that contains variables relating to the inventory in the RPG demo.

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

Now I have one last question: what’s the best way to put in a quantity (number of items currently held by the player)? Should I use an integer or a float? Or something else?

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [October 17, 2024, 6:13am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/13 "2024-10-17T06:13:21Z")

</div>

likely an Integer as you cant have a fraction of an Item, however your cost/sale might be floats

---

<div class="post-metadata">

**Author:** ![CurleeD85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CurleeD85](https://forums.unrealengine.com/u/CurleeD85)\
**Post date:** [October 17, 2024, 6:20am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/14 "2024-10-17T06:20:49Z")

</div>

I’m not likely to use decimal numbers, so I’ll just use integers for each.

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [October 17, 2024, 11:34pm UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/15 "2024-10-17T23:34:54Z")

</div>

Another thing you could use is a map! Look into those!

You could have the object as the first half (key) and the int as the second half (value) then any time you need you call the key and it returns the value! 🙂

---

<div class="post-metadata">

**Author:** ![CurleeD85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CurleeD85](https://forums.unrealengine.com/u/CurleeD85)\
**Post date:** [October 18, 2024, 5:24am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/16 "2024-10-18T05:24:20Z")

</div>

I don’t know if you saw the screenshot I posted earlier of the structure I made, but I made a struct then a data table based on it. So now, I’m at one last impasse: how do I cast to a variable within the struct variable? Like, say, I want the game to detect whether or not the player not only has a certain item but also the correct number of items? (Which would be, in this case, the ItemName (Name) and Quantity (Integer) variables.)

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [October 18, 2024, 7:31am UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/17 "2024-10-18T07:31:37Z")

</div>

Yes, it looks like here you need a map.

The first half of the map would be a Name, the second half (value) would be a struct based on that name. Then the struct would hold all of the data related to that name. The map puts them into a searchable list (you would use “Find” to get the one you need with a name input).

---

<div class="post-metadata">

**Author:** ![CurleeD85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CurleeD85](https://forums.unrealengine.com/u/CurleeD85)\
**Post date:** [October 18, 2024, 5:32pm UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/18 "2024-10-18T17:32:35Z")

</div>

Would you happen to know of any good tutorials on how to make structs work with BPs that cast to their individual variables within a struct? That is, one that works with UE5?

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [October 18, 2024, 5:46pm UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/19 "2024-10-18T17:46:56Z")

</div>

Sorry, that’s what I’m trying to tell you.

You NEED a map. This will not work unless you use one. ☹  
Unless each item has its own struct, you can’t search through a bunch of structs for the one you need, you have to specify. The map would allow you to specify which one you need by passing in a string, name, or text variable (or other kinds but for this stick to one of those three).

Otherwise, you can just use “Set Members” and then “Set Struct” to save values,  
and “Get” then break the output pin on the struct to Get a value- but you have to have already specified the struct, as I stated.

Also, casting doesn’t do what I think you think it does… It’s not a “Get” node, it’s a reshaping node. You cannot cast to variables (though you can cast a struct to another struct). What that means is you can make struct A BEHAVE AS struct B. Another word for cast is mold, if that helps?

---

<div class="post-metadata">

**Author:** ![CurleeD85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CurleeD85](https://forums.unrealengine.com/u/CurleeD85)\
**Post date:** [October 19, 2024, 7:18pm UTC](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129/21 "2024-10-19T19:18:14Z")

</div>

Are you referring to a map container type for the variables within the struct?

[Next page](https://forums.unrealengine.com/t/gameplay-tags-item-quantities/2070129.md?page=2)
