Custom weapon editor (Unreal Engine)
This was my honours project, I started it in order to learn about modular programming and games tools development. This tool aims to cut down on repetitive tasks needed for creating new weapons and exposes variables to make the process designer and artist friendly.
What I learnt:
Observer pattern, C++ delegates, Unreal Engine dispatchers/events
Unreal Engine editor utility widgets
Unreal Engine custom data assets
Read/writing project content files from code
Creating children of custom classes and objects through code
Code abstraction and decoupling
Unreal Engine Gameplay Ability System (GAS)
Editor features
Custom Viewport
Displays currently selected weapon as it would appear equipped by the player character. Updates live as any variables are being changed. Allows to adjust the weapon and see outcomes without having to run the game. Camera placement and angle can be adjusted for closer inspection.
Hierarchical Inheritance Structure
To reduce repetitive work the weapon editor separates weapons into classes and subclasses. This allows to avoid setting up a similar type of weapon from scratch by copying existing data assets. Enforces a file and object structure that keeps weapons organized and easier to parse through.
Quick Editor Actions
These are buttons within the editor that provide the ability to create new data assets based on existing ones, delete or save changes on existing data assets or even create and spawn weapon blueprints within the level based on the selected data asset. Other operations allow you to refresh all weapons within the currently open scene to make sure they are reflect any changes made to their data assets.
How the weapons work
Base Weapon Class
The weapons are created from a single base class that takes a data asset. When equipped, weapons give the character functionality via gameplay abilities.
Custom Data Assets
Weapon data is stored in custom Unreal Engine data assets. These assets hold all adjustable properties of weapons like mesh, animation set, attachment socket, hit-box, ability set and stats. The data assets can be accessed and modified directly through the editor.
Gameplay Ability System (GAS)
To store/grant abilities, modify stats, play animations or SFX, the project uses the Unreal Engine framework called the Gameplay Ability System. Here is a flowchart showcasing examples of stats, abilities, characters, weapons and how they interact.
Functionality (Atomic Actions)
Atomic Actions are a concept to break down abilities into simple executions that can be heavily modified through variables to remove the need of programming for the creation of unique functionality of weapons. This example showcases a simple melee attack chain modifiable by adding/removing array elements to adjust number of attacks as well as the array holding information on individual attack swings like use of root motion, attack animation, recovery animation, animation play rates and damage multipliers.
This system was inspired by the GDC talk "Smart Guns: Building a Modular Weapon System Using Behavior Trees".
Scalability
Weapon Handler Component
Equipping, storing necessary data and interacting with the weapons is handled through a custom component. This allows to create a separation between user and weapon. Having weapon handling logic be stored within a component makes extending the use of weapons from player to AI enemies as simple as attaching a component.