Alessandro Belli

Inventory System Plugin for Unreal Engine 5

3 min read Projects c++ Unreal Engine 5 unreal engine

Role: Sole Developer
Duration: 2025–Present
Technologies: C++17, Unreal Engine 5.6+, Blueprints, GameplayTags, FastArray Replication
Repository: github.com/alessandrobelli/InventoryPluginUE5
License: MIT (Open Source)


The Inventory Grid

The Challenge

Inventory systems are a fundamental feature in games, yet building one that actually works in multiplayer is surprisingly complex. Most tutorials cover single-player drag-and-drop grids, but fall apart when you need server-authoritative validation, efficient network replication, and modular item definitions that don't require a new class for every sword variant.

I built this plugin to solve that problem properly — a production-ready inventory system with full multiplayer support, designed as a reusable UE5 plugin rather than project-specific spaghetti code.


What I Built

Fragment-Based Item Architecture

Instead of creating inheritance hierarchies (BaseItem → Weapon → Sword → IronSword), I implemented a composition system using FInv_ItemFragment. Items are defined by combining fragments:

  • GridFragment — Size in inventory (2×3 slots for a greatsword)
  • ImageFragment — Icon texture and dimensions
  • WeightFragment — Affects player movement speed
  • StackableFragment — Max stack size, current count
  • EquipmentFragment — Socket attachment, stat modifiers, spawned actor class
  • ConsumableFragment — Health/mana restoration effects

This means a "Health Potion" is just a manifest with ConsumableFragment + StackableFragment + ImageFragment. No new C++ class required. Game designers can create items entirely in data.

Server-Authoritative Multiplayer

Every inventory operation validates on the server first. The client requests an action, the server checks if it's valid (has space? owns the item? correct stack count?), then replicates the result back.

I used Unreal's FFastArraySerializer for efficient delta replication — only changed items sync over the network, not the entire inventory. The system includes:

  • Server RPCs for add/remove/move/equip operations
  • Client RPCs for UI feedback
  • Comprehensive delegate events (OnItemAdded, OnItemRemoved, OnStackChange) so UI stays synchronized

Spatial Grid UI with Drag-Drop

The visual inventory uses a proper spatial grid where items occupy multiple slots based on their GridFragment dimensions. Features include:

  • Multi-slot item rendering with configurable padding
  • Drag-drop between inventory slots, equipment slots, and world
  • Slot highlighting during drag to show valid placement
  • Right-click context menus for split/drop/consume actions
  • Hover tooltips with item stats via composite widget pattern

One specific bug I fixed: drag operations were interfering with grid boundary detection. I added an bIsDragging flag to temporarily disable boundary checks during drag, then properly re-validate on drop.

Equipment System

Equipment slots support visual actor spawning — when you equip a sword, an AInv_EquipActor spawns and attaches to the character's skeletal mesh socket. The system includes:

  • Configurable equipment types via GameplayTags
  • Stat modifiers (strength, defense bonuses) applied on equip
  • Automatic cleanup when unequipping

Weight System

Total inventory weight calculates automatically from WeightFragment values and affects player movement speed. This creates meaningful decisions about what to carry.


Technical Decisions

GameplayTags over Enums: Items are identified by hierarchical tags (GameItems.Weapons.Sword.Iron) rather than enum values. This scales better and allows runtime querying without code changes.

Plugin Architecture: Built as a self-contained UE5 plugin with clean module boundaries. Projects add it to their Plugins folder and reference the module — no code surgery required.

Composite Widget Pattern: UI widgets use UInv_CompositeBase for flexible composition. The item description panel assembles itself from available fragments rather than hardcoding every possible stat display.


What I Learned

This project pushed me to understand Unreal's replication system at a deeper level than typical gameplay programming. Debugging desync issues between client and server taught me to think carefully about authority — who owns the data, who can modify it, and how changes propagate.

The fragment-based architecture came from frustration with inheritance-heavy tutorials. Composition made the system dramatically more flexible without sacrificing type safety.

Building a proper plugin (not just game code) required understanding UE5's module system, including Build.cs configuration, public/private header separation, and API export macros.


Status

Active development. Currently used in personal projects with planned features including container systems (chests), item durability, and inventory sorting/filtering.