This project was a part of my final year of my bachelors degree. It involved designing and producing a game mechanic in Unreal Engine that could be used in a finished a game. I chose to create a shooting system similar to those that can be found in games like counter-strike and valorant. This meant that I needed to have simple hitscan guns that can have repeatable recoil patterns.

The guns are very simple. An abstract C++ class was created that held the basic functionality for the gun such as shooting, reloading and fire rate. Shooting was simply done by performing a linetrace and accessing an interface on the object that has been hit, this allowed functions to be performed on the hit object that can allow it to take damage, break or anything else that was required. Reloading was done by resetting the ammo count after finishing a timer, this could have been better by linking it to animations however my primary focus for the project was making recoil patterns easy so I didn’t get around to adding animations. Child classes were created for different types of guns, specifically fully automatic and semi-automatic, to control how they shoot. The base class contained an interface for input to tell the gun when the fire key is pressed and when it is released. For a semi-automatic gun, shooting is very simple as the gun needs to fire when the fire key is pressed provided the gun is not on cooldown. Fully automatic guns are slightly more complex, when the fire key is pressed a bool is toggled to tell the gun that it is currently firing, then in the update function the gun will check if it is currently firing and shoot if it is not on cooldown.

Recoil patterns were much more complicated. The basic concept for the recoil pattern was to store a list of Vector3s that would rotate the camera each time the gun is shot. The list entry that was used would be the same as the number of bullets that have been fired before the recoil resets. Implementing this was very simple, the main difficulties come with creating an editor that makes creating recoil patterns much easier. A very simple editor for the recoil patterns was made by using editor modes. An editor mode was created that allowed me to click and add a new point to the recoil pattern. These points could then be edited by clicking and dragging them around. This worked for editing recoil patterns however, additional UI was needed to save and load recoil patterns to ensure that they could be edited after being initially created. This UI was created using Slate which was torture however, it allowed me to create simple UI that could execute functions on the editor to load data from previously made recoil patterns, save new recoil patterns and toggle point visibility in the editor.

Overall, this project taught me a lot about using Unreal Engine and how useful custom editors can be. Furthermore it also showed me how useful proper commenting can be in unfamiliar code bases as a lot of documentation for Unreal Engine can be found in the comments of the source code.