Download

Best way to implement an item system?

Hi all!

I hope this isn’t a stupid question, but I just started with game development and the unreal engine and as a personal project I want to create a game with an item system that (roughly) has the following functionallity: drop/pick functionality, placable and iventory-only items, crafting system that requires finding new recipes.

I’ve been carefully following along with a couple of tutorials on item systems, but I see one ‘flaw’ with all of them. They use a struct to set which properties an item has (for example name, weight, damage) and then give the player character a aray that contains all the names, weight and damage for all the items in the player’s inventory.

The problem I see with this is that implementing a complex crafting system becomes much more dificult with this, I was thinking more of trying to give every item an ID and then have the player character only store the ID’s of the items inside the player’s inventory. (similar how minecraft used to work)

Is this a completely crazy idea? How would you guys go about implomenting this kind of item system in the unreal engine?

PS: I apologize if I’m not using the correct terms, please feel free to correct me.

Sounds like what you are looking for, is something Wildcard did with their system.
I mean, it may even be beneficial for you to download the ADK from the launcher and open up their setup and take a look.
If you look at the item ID lists (Google: Ark Item ID), each item has (or did originally, they stopped giving IDs to everything) and the commands to give items via blueprint as well.
I think what you are asking isnt going to be hard, but, very time consuming. If you are new, get your learning hat on lol.
There are some inventory setups and crafting/building setups in the marketplace that are not that expensive. Maybe look into one of those and see how they did it.

Online:
Server manages database (or cached database) directly; then replicates struct object to clients.

Offline:
Read/Write local database directly (SQLite for example) then feed UI with db values.

Both cases, it’s important to avoid allocation of memory. In Marketplace there’s a few inventory systems built on Blueprints, but they allocate GC (BAD!)

i.e: they create a new object or new actor for each inventory item and destroy/recreate these objects every time something is moved/added/removed from the inventory…

For things like this you have to put aside “object oriented programming” and think about the data (data-driven programming).
For example: a whole inventory can be just an array of bytes (as long as you have less than 256 classes of items), instead of storing a whole UObject*, just to tell an inventory that a player has these and that items… The difference in allocation is abysmal.
Whenever you have to query info about the item, just look up a Singleton object (or a datatable) to check which item that byte Id is referring to and retrieve all of its cosmetic data, stats, etc.