Devlog 4: Inventory System & Item Assets


Hey again, thanks for reading! This week, I focused on setting up object interactions, inventory management, and UI integration to make picking up and storing items functional. I also started creating assets earlier than expected, which has already helped with testing. While most of the system is working, I ran into some issues with inventory updates that I’ll go over below.

Implementing the Item System with ScriptableObjects

To make the inventory system modular and scalable, I used ScriptableObjects to store item properties. Instead of hardcoding item details directly into scripts, this method allows items to exist as separate assets that can be modified without changing code.

Each item has attributes like a display name, description, type (resource, equipable, or consumable), an icon for UI, and a reference to its in-game object when dropped. Items that should stack, like wood or stone, have a canStack attribute with a maximum stack amount, ensuring stackable items don’t exceed their intended limits.

This approach makes adding new items much easier—I can simply create a new ScriptableObject and assign values instead of manually modifying scripts.

Creating Physical Item Objects

For an item to exist in the game world, it needs a physical representation. I set up prefabs for different items, ensuring each has a sprite, physics properties, and an interaction system. These objects contain a reference to their ScriptableObject data, meaning they already "know" what item they represent.

Throughout the process of making my game I've been referring to a variety of tutorials, many of which are meant for 3D games. To make sure things function correctly in my 2D environment, I ensured that:

-  Items use 2D colliders for detection instead of 3D ones.
-  Movement and physics rely on Rigidbody2D components.
-  When dropped, items rotate only on the Z-axis to stay within the 2D perspective.

This setup allows items to behave consistently, whether they’re collected, used, or dropped back into the world.

Implementing Interactions in a 2D Space

To allow players to pick up items, I needed to create a raycast-based detection system. Since this is a top-down 2D game, some adjustments were necessary to make interactions work as expected.

Instead of relying on a camera direction (which is typical in 3D games), interactions are determined by the player’s last movement direction. If the player moved left, for example, the system checks for objects to the left when interacting.

Rather than casting a straight-line ray, I adjusted the system to check within a small circular radius around the player, ensuring they can interact with nearby objects naturally. This method works well because the player isn’t locked to one direction of interaction—they can pick up items in their general vicinity rather than having to aim precisely at them.

Each interactable object has a prompt that appears when the player is within range, displaying messages like “Press E to pick up [Item Name].” When the interaction is confirmed, the item is removed from the world and added to the inventory system.

Building the Inventory System

The inventory system is designed to:

- Store collected items and display them in the UI.
- Support stackable and non-stackable items.
- Handle item addition, removal, and interactions dynamically.

When the player picks up an item, the system first checks if the item is stackable. If there’s already an instance of that item in the inventory, it increases the stack count instead of taking up an extra slot. For non-stackable items, a new inventory slot is created.

To keep things organized, each inventory slot contains a reference to the item type and the quantity of that item. If the item is consumed or used, its count decreases, and if the count reaches zero, it’s removed from the inventory.

Creating the Inventory UI

Although I might refine the UI later, I set up a working inventory interface that dynamically updates when items are added or removed.

The UI consists of:

- A grid of item slots, each displaying an icon for the stored item.
- A stack count indicator for items that can stack.
- Real-time updates when the player picks up, drops, or consumes items.

I ensured that the inventory layout scales correctly in the Canvas system so that it works across different screen sizes without overlapping or clipping.

Below is a video that shows where I'm currently at.  All of these videos have honestly been shit quality and I'm not sure why but whatever. 

Current Issues & Debugging

 Initially, I was having issues getting my e-interactions to work. To remedy this I resorted to manually setting it instead of relying on the input system (even though it seemed to be set up properly). This worked and allowed the interaction system to workmsmoothly. Currently, when the player walks up to an item they will be prompted to pick it up, and by pressing e the item is successfully added to the inventory. However, I still have an issue with the UI not updating, but I haven't had the chance to work through this issue yet. 

Debugging Steps I'm Taking:

- Adding Debug Logs – I’m printing debug messages at every step of the item pickup process to pinpoint where the failure happens.
- Verifying ItemData Assignments – Making sure every item prefab has the correct ScriptableObject assigned so the game knows what it’s dealing with.
- Checking Inventory Initialization – Ensuring that the inventory properly initializes slots at game start, preventing reference errors.

Fixing this is a top priority since a working inventory system is essential for the game’s mechanics and I really can't move forward with the crafting mechanics until this is sorted out. I have a feeling that I'll be able to fix out this issue pretty quickly now that I know the root cause.

Early Asset Creation

Even though I originally planned to wait until March to start on game assets, I decided to begin early. I lost a good amount of time to the whole inventory issue so I decided that it would be best to step away from it for a few days and focus on something  else so that I could make up for lost time and still have a productive week. Honestly, making the game art has been really fun and I'm really happy with the way things have been turning out.

I created:

- Over 20 item icons, which helps with visualizing the inventory system.

-  Several enemy designs, which will be used in the game.
-   A potential background for turn-based combat in the forest.

My process of making asset carried based on what the asset actually was. Most of my character/enemy assets were drawn in pixelorama (a free pixel art software), and others such as the item assets were made using images/illustrations what were converted into bitmaps and had colour added back into them after. Both methods have been working well and I'm really looking forward to being able to plug everything in and ditch my ugly placeholder assets.  

Below are a few examples of the assets I made. I love my little forest occultist guys and my diseased villager. 





Next Steps

For the next update, I plan to:

- Fix the inventory update issue so items appear correctly in the UI.
- Start integrating item interactions (e.g., consuming food, equipping gear).
- Refine the interaction system further, ensuring smooth detection of objects.

- Finish the entirety of this stupid inventory system and set up the crafting.

That’s it for this update! Next time, I’ll share more progress on item handling and interactions.

 

Leave a comment

Log in with itch.io to leave a comment.