Resource Management



My Resource Management project is a Unity project where I made some systems for a "resource management/harvesting" game. I tried to make it very flexible and modular. Where the concept of an item is fairly abstract and you have a lot of customizability of your inventory.

Resource system

In this project I call the things placed in the world that you harvest, ”resources”. Think of it like a tree or a rock. A resource contains a drop table of items, for example stone and coal, with min & max amount and an overall drop percentage per item. Items have stats of harvesting speed, dmg, strength tier, type tag and a stack size. This makes it so a tool, for example an axe is just an item with specific statsStrength tier & Type tag
The items "strength tier" and "type tag" are not as straightforward as the other stats, so let me explain.
First up the type tag explains what type of item it is, for example if you want to have a specific type of item that can destroy rocks, then it could have the tag pickaxe. Then the rock resource also needs to have the same tag listed as a "can harvest tag". If this is left empty then every item and an empty hand can harvest the resource. Both items and resources can have multiple tags, that is useful if you’d like to make a multitool, or if your resource can be harvested by two or more tools/items but not all of them.Then we have a strength tier. If you want to have resources that can only be harvested by a tool of a certain tier, let's say you want to be able to have upgraded versions of the same tool in your game. You have a wood axe, and try to cut down a very big tree, you can't. But the upgraded stone axe can cut down that tree. But now you might be thinking, why not just add more tags. Then this is where you're wrong. If you for example have a "Axe 1" tag and a "Axe 2" tag, then everything that could be harvested with the lower tier would also need to have the higher tiers tag on it. So that would quickly become a big mess when using this system in a full scale game.


Inventory system

For the inventory I have one script that is the abstract inventory, the one that is responsible for how many slots the inventory has as well as what's in it and where. Then I have an Inventory UI script for the visual and interactive part of the inventory. The inventory UI can own multiple inventory’s that can be switched between when you play. Lastly I have an Inventory UI Manager for not making the inventory dependent on the inventory UI.A problem I encountered very early on when creating the inventory is “how should it interact with each other, if you have a chest or/and hotbar?”. This was difficult because I wanted my inventory to be fairly modular. I wanted the user to be able to decide where it’s located on the screen. If they have one or more UI. If they have a hot-bar and such. I wanted the user to be able to design a game that uses a big amount of inventories, for example if they want to have backpack upgrades or extra storage in clothing items. So for that the player would need to be able to have access to multiple inventories in one “UI” for that to be possible. I came up with having buttons on the side for the inventory’s UI, so that they are able to switch between inventories and move items between them. I could also have made the inventory grow on the same grid with the inventory becoming “scrollable”. But that could have resulted in it being unclear where the old inventory ends and the new one starts, and becoming messy when the inventory becomes too large. (If I would have had more time, I would have liked to add a scrollbar both for the switches and for the inventory display). But after making the decision of having multiple inventories in one UI I was thinking, what if the user wants chests and other storages to open in a separate window as in Minecraft. So I made it possible to have both with both being the same Inventory UI component. I made this with the fact that only one inventory UI can be listed as a “storage UI” inside of my UI manager. So then all open storages opens and adds itself to just that inventory UI. I would say, I managed to make my inventory system pretty modular!Something I would have liked to work more on is the way to move items in inventories. I have the normal move one stack, and move half of the stack option. But I would also like to be able to drop one item of the stack you are currently holding, to the slot you are hovering. Also a quick move for moving the entire stack to the first most relevant spot it finds. I had this functionality before I added the ability to have multiple inventory UIs, but then I just didn’t have the time to fix it.


Storage & Crafting

My two interactible stations are storages & crafting. The storage is basically only an inventory that is either connected to your players Inventory UI or a separate one. And the crafting is a collection of two inventory UIs one that is input and one that is output. The crafting has recipes that is a ScriptableObject that has two lists of items with item amount, one as input and one as output.


What I learnedIn short, during this project I improved my ability to structure modular systems and think a lot more about my code structure than I’ve had the time to before.This project feels like a reflection of my previous Unity project Build Your Gun. In that project I had a problem with limiting the modularity of the system. I also had difficulties making decisions when two or more components were "talking to each other", and how they were supposed to be connected. Because of that my structure was not as well thought out as I would have hoped. But we learn from mistakes, so this time I wanted to challenge myself in just that. So before I started coding I sat for a couple of days and planned out the systems structure, inheritance and what should communicate with what. Even though these systems structures were a lot harder to plan out than my previous projects, I personally think it turned out a lot better. I’m satisfied with the result of my project for what it is, but like everything we do there is always room for improvement.If I would continue to work on this project I would like to focus on the spawning of resources. A way of having a grid where the "neighbours" know each other so I can make a way to have resources of different sizes. And I would also like to have 1 big grid instead of a few small ones where each grid slot somehow knows what can spawn on top of it (like a biome). I want this mostly so the player can have more control over the world. Like to be able to destroy and place terrain, or to be able to place their own chests and craft stations.


Noa Johansson