Storing Inventory Item Properties

Hi everyone,

I’m working on creating an inventory system right now for my RPG game, and currently I’m having some trouble wrapping my head around the best way to set it up.

I have a bunch of properties that need to be stored within each item (Name, Icon, Model, EquipArea, etc.).

My main questions are how to write this out so:

  1. I can store each item in an inventory grid slot (I already have the grid setup so that it can show an icon of my choosing in each slot).

  2. I can expand upon it for each item I create.

Thanks in advance!

You need you’re objects to be able to switch between those states :

  • They are physically in the scene,
    with a mesh, renderer, collider etc.
    Like a sword on the ground.
  • They are in the bag and not visible anymore.
  • They contain informations like name,
    description, icon, price etc. The
    player is carrying them, so they are
    visible and parented to a bone,
    without a collider.

When you pick them up, you can either deactivate them and parent them to the player, or destroy them entirely. But then, you must be able to reinstantiate them later.

Anyway, there isn’t a best way to do an inventory. I suggest you take a look at the corresponding tag here.

your wanting to create a generic item class.

A class is basically a custom type.

Integers are a class. they contain a number and that number can have functions like addition and subtraction and stuff done to it.

You want to create an item class that represents a general item.

You then want to create an inventory class, an inventory class should MAINLY be an array of items (which are made through the item class declaration) and then how things are added and removed from the inventory.