Inventory System
Development of the Inventory and Interaction System
I’m starting to design and program the inventory system, reusing a schema from a previous project. But before diving into the details, I need to implement the system for interacting with some blocks. After considering several options, I believe the most versatile approach is to allow the player to click on objects as long as they are within a certain distance.
I’ve implemented a class called InteractableManager
. This class detects when the left mouse button is pressed and casts a ray to find an object with a component called InteractionCollider
, which it then queries for its InteractableBlock
. This way, only interactable objects have Unity colliders, as the "voxel" rays I use are not very precise, and precision is essential here.
Now, let’s talk about the inventory. A year ago, I experimented with different inventory systems in another project. Generally, inventory systems use slots, but some games have innovated to provide a unique experience. For example, Resident Evil 4 uses objects of different sizes to simulate a well-organized inventory. On the other hand, No Man's Sky's inventory system, though not my favorite, stands out for its uniqueness.
Although this project is inspired by Project Zomboid (at least in terms of camera and movement), its inventory system is functional but doesn’t significantly enhance the gameplay experience. In games like Zero Sievert, looting can be a stressful experience due to the "searching" mechanic in containers. I found this tension interesting and explored it in my inventory system.
I developed a slotless inventory system where items are scattered in containers, and the player must drag them into their inventory. Organizing the inventory offers advantages like quicker access to items, which is useful in dangerous situations. This system also allows storing items within others, facilitating a dynamic crafting system. For example, a bullet might contain a casing and gunpowder, and adding pellets transforms it into a shotgun shell.
The goal now is to integrate and refine this inventory system. Previously, opening the inventory always displayed two large windows: one for the backpack and another for the external inventory, which confused players. This time, I will always display the inventory along with the equipment in sections: backpack, hands, clothing, and utilities. When inspecting another inventory, a second, graphically distinct window will open to avoid confusion.
I found a perfect provisional asset: a pixel art backpack with animations and necessary layouts. I created a new block in the form of a refrigerator, which, when interacted with, displays a window with two inventory areas: freezer and fridge. Each inventory will have a unique display. I also resolved reference issues when interacting with multiple containers simultaneously, allowing dynamically opening multiple inventory windows. (You can found the link to the backpack asset in the next image).
I will finish this entry by discussing the mechanics of dragging items within inventories. To populate them, I will use "LootTables," a ScriptableObject
that contains generative content information, similar to loot systems in games like Minecraft. Each container generates "coherent" loot according to its type: refrigerators, drawers, etc.
Once items are generated, they are visualized in the inventory through a list of SerializedInventoryItem
, which contains information about the item’s position, rotation, ID, and metadata. The position is managed in viewport coordinates, allowing items to be dragged within the available area. If an item is dragged outside the inventory, it returns to its last valid position, but in the future, dragging it out should drop the item, and dropping it onto another inventory should move the item there.
That's all for this week's update! I’m excited to keep refining these systems and share more progress soon. Thanks for reading, and stay tuned for more updates!
P.D: I’m releasing the new version for you to review the system and leave any comments. I’m also including the compiled version of an early build of the previous project where the inventory system—or at least the concept—is more developed.
Files
Get Z-Engine
Z-Engine
Status | Prototype |
Authors | Argendel, [Random Adjective] |
Genre | Survival, Simulation |
Tags | building, Minecraft, Sandbox, Singleplayer, Top down shooter, Voxel, Zombies, zomboid |
More posts
- Graphic StyleJun 08, 2024
- Personal InventoryMay 25, 2024
- VerticalityMay 08, 2024
- XRayMay 06, 2024
- FOVMay 02, 2024
- Colliding WallsApr 30, 2024
- MiniaturizationApr 26, 2024
- First ProblemsApr 24, 2024
- World Edit ToolApr 11, 2024
Leave a comment
Log in with itch.io to leave a comment.