Skip to main content

Creating 'Organic' Inventory Systems in C#

· 2 min read
Thang Le
Senior Lead Engineer

Inventory System

Breaking the Fourth Wall

In horror, immersion is everything. The moment a player opens a flat, 2D menu that pauses the game, the tension is broken. They are reminded that they are playing a game. To solve this, many modern horror titles (most famously Dead Space) use Diegetic User Interfaces—UIs that exist within the world of the game.

Architecting a Diegetic Inventory

Building an "organic" inventory system in C# requires a different approach than a standard HUD. Instead of a Canvas-based UI, we use 3D objects and World-Space Canvases attached to the player's character or a handheld device.

public class DiegeticInventory : MonoBehaviour {
[SerializeField] private Transform _uiHologramAnchor;
[SerializeField] private InventoryData _data;

public void ToggleInventory() {
// Logic to animate the hologram in/out
// Ensure the game does NOT pause!
}
}

The Challenge of Real-Time Interaction

When the game doesn't pause, the inventory becomes a source of tension. The player must manage their items while potentially being hunted. This requires:

  1. Streamlined UX: Actions like "Quick Heal" or "Reload" must be intuitive so the player doesn't fumble while panicked.
  2. Physical Presence: The inventory "screen" should cast light on the player's face and the environment, reinforcing its place in the world.
  3. Animation Integration: The player character should look down at their device or backpack, creating a visual cue for the player's vulnerability.

C# Best Practices: The Data-Driven Approach

To keep the system performant, we use ScriptableObjects for item data and a Messenger/Observer pattern to update the UI. When an item is added to the InventoryData ScriptableObject, it fires an event that the DiegeticInventory listens for, updating the 3D representation without needing to poll every frame.

By removing the "safety" of a paused menu and integrating the inventory into the game world, you force the player to stay engaged with the horror even when they are just trying to manage their resources. It's a small change that has a massive impact on the overall feel of the game.