Best way to make items for inventories?

Hello,

I want to make an item for an inventory system but I don’t know where to start… First of all, I was wondering what is the best way to create an item? I do for an instance need a couple fixed variables to apply for all child-items, like an integer for StackSize, a boolean for IsStackable, etc. and at the same time be able to store it in an inventory, so would probably need a variable for an item-id as well. Also, some items that are child of the parent class would have a visible representation in the world. I was just wondering… What would be the best class so use for this?

I know I could use an actor class, but is it really worth it? Are the performance-cheaper methods? With an actor, I could store it in an array of actors in order to make up the inventory, and collect all kinds of variables I want like the ones mentioned above. I could also add a static mesh component in order to make it visible in the game world at any time I’d like, for example when I drop it.

Or, should I just use an empty class? If so, would I be able to do all I want, which is storing variables, create child-classes, does it support static mesh components, etc.? If not, which other methods could I use in order to achieve what I want?

All help is highly appreciated, thanks in advance! :slight_smile:

~Stefan

I would start by defining a data structure (you would use a C++ class for this) that defines some base properties of an inventory item such as a name,a description , a unique identifier, whether or not the item is consumable or can be equipped by the player. This what you properties you put in your item depend very much on the game you’re making. Is it a role playing game, adventure game, first person shooter or a puzzle game?

Once you have your data structure defined, you can then leverage it in different contexts. An item like a key for example might not ever have an actor associated - when you go to open the door in game, you merely check the player’s inventory for the existence of the particular key required to open up the door.

For something like a weapon that a player would be holding, you could create the actor for the weapon and position it in the world when the player switches to it or equips it.

Okay, I will try this! I kind of knew how I would approach already but it was nice to get some guidelines, because I wasn’t really sure. That’s why I made this thread anyways. So thanks for your help! :slight_smile:

I followed this guys tutorial on how to make an inventory system helped me to get an idea of how it all works then i changed it to my own, its covered in lots of different videos but certainly worth the watch. he doesnt say how to model the actual static meshes for that you would need to use something like blender.
Anyway for all the functionality of an inventory this is the link to his first video in his series. Hope it helps.