This project page details the work completed during the 'Programming for Game Engines' module at Teesside University (Year 2, 2025 - 2026). The module focused on creating a modular inventory plugin for Unreal Engine 5, designed specifically with developers in mind—ensuring it is robust, efficient, and accessible for use by all. The module began with a brief re-introduction to programming with a Connect Four demo created entirely in C++.
Component-Based Architecture: Designed the system using components, allowing the inventory logic to be reused for any actor (player, NPCs, chests) without modifying their core class code.
Data-Driven Design: Implemented a pipeline using Data Tables and custom Item Data structs. This allows designers to add or tweak items (Name, Weight, Mesh) in the Editor without needing to recompile C++.
Event-Driven UI Optimisation: Replaced performance-heavy Event Tick checks with Event Dispatchers. The UI only updates when the backend broadcasts an OnInventoryUpdated event, significantly reducing CPU overhead.
Algorithmic Logic (Iterative Merge Sort): Implemented a custom Iterative Merge Sort adapted for Unreal's TArray architecture. This allows players to sort their inventory by weight with O(n log n) efficiency.
Smart Item Stacking: Programmed robust inventory logic to handle duplicate item acquisition. The system automatically detects existing stacks, validates the maximum stack size, fills partial stacks first, and seamlessly overflows excess items into new slots.
Interactive UI & UX: Visualised the inventory with a scrollable menu and context-sensitive inputs. Players can use the Scroll Wheel to navigate, Left-Click to inspect item details, Right-Click to drop items, and a dedicated button to trigger the sort algorithm.
Physical Item Interaction: Bridged the gap between UI and Gameplay by implementing OnBoxBeginOverlap logic. When a player walks over an item, the actor automatically identifies the player's component, verifies weight limits, and seamlessly adds itself to the inventory data before destroying the physical object.
Dynamic Board Architecture: Utilised vectors containers opposed to arrays, allowing the board size to be easily modified or scaled at runtime.
Input Validation: Implemented a fail-safe input loop, preventing the program from crashing or entering infinite loops if a user enters non-numeric characters or inaccessible columns.
Win Detection Algorithms: Developed a custom checkForWinner() function that scans the board in four distinct directions (Horizontal, Vertical, Diagonal Left, Diagonal Right). The logic includes boundary checks to prevent "Out of Bounds" memory access errors when checking edges. It also takes note of the boards size (total cell numbers), for checking for draws.
"Gravity" Simulation: Created an updateBoard() function that iterates from the bottom of the grid upwards. It identifies the lowest available slot in the selected column to simulate a physical token dropping.
Language: C++ & Blueprint Visual Scripting
Engine: Unreal Engine 5
Core Systems: Modular Inventory Architecture, Event-Driven UI, Data-Driven Item Pipeline, Enhanced Input System
Core Concepts: Component-Based Design, Observer Pattern (Delegates), Memory Management (Pointers & References), Algorithms (Iterative Merge Sort), Data Structures (Structs & Arrays)
IDE: JetBrains Rider, Visual Studio
Tools: GitHub
This project being my first delve into C++ within Unreal Engine led to a lot of early confusion, getting used to all the macros and other specifics proved quite the challenge - one I overcame in the end.
Adapting to Unreal C++: Coming from standard C++, adjusting to Unreal’s specific macros (UPROPERTY, UFUNCTION) was a steep learning curve. I initially found it tricky to understand why certain variables needed exposure to the reflection system, but this project solidified my understanding of the Engine's architecture.
Data Structures & Sorting: Implementing Data Table for the first time was confusing, as was adapting a Merge Sort algorithm to work with those custom structs. Figuring out how to properly query the table and then sort the resulting array gave me much stronger confidence in handling game data.
Event-Driven Optimisation: Learning to use Event Dispatchers was a key moment for the project. I initially relied on Event Tick for updates, but once I understood how to broadcast events, I realised how much cleaner and more performant the code became. It was simple to implement once I understood the concept, but a great improvement to the project.
Complex UI Data Binding: I faced a persistent bug where the Inventory UI wouldn't display item data despite the backend logic working. Debugging this required me to dive deep into how UMG binds to C++ variables. I also had to implement custom logic to detect specific mouse inputs (Left-Click to Inspect vs Right-Click to Drop) on the same button, which was a challenge in UI event management.
Algorithmic Logic (Connect Four): My biggest hurdle in the C++ prototype was implementing efficient Win Detection. While I understood that checking only the newly placed token is optimal, I struggled to implement that logic successfully. I compromised by implementing a system that scans the entire board state each turn. This taught me the trade-off between "perfect" optimisation and "shipping" functional code.