Ok, let’s say your item has different values over the time. Like you have a magazine for a weapon or something and you need to save it’s ammo value.
(I would also save the properties, even if you don’t intend to have different values for the same item BP. Maybe you change it later and than it’s a big mess to fix it)
So with this ammo value, there are a few more things you would save with an item:
- Name
- Icon
- Describtion
- Model
- Gold Value
- Max Ammo
- Current Ammo
Now let’s say you have a parent class for all your items.
This parent class has ALL variables. So for food it would have a hunger value. For a weapon it would have the damage of that weapon and so on.
All child classes, like the magazine, or an apple now get the same variables.
Most of them only need there own but this makes it easier for you to store the properties.
Instead of making all variables single, you make a struct called “Item Properties” in your main class with all the variables. I did this in C++ BlueprintReadWrite, but i guess Structs are the same in BP.
So you have a struct with all the values. Now you just fill them inside your specific item BP. Like giving them a name, a describtion and so on.
Now, with this Struct type that holds all properties, you create an Array of that Struct inside your Player. This makes it easy to save the properties, because you only need to plugin the struct node into the array struct node and not every single variable.
It’s not
Name = Name
Gold = Gold
…
It’s only
Struct = Struct
Remember to save the properties always to the same index that the item has in the Inventory Items (int) array.
So, now you can pull everything from the struct. If you want to display the items inside a HUD you would just get the struct, break it, uncheck everything you dont need to see of that struct on the left side in the options and get the icon.