Shooting mechanics
With the cover system out of the way I can start making progress on the rest of the shooting mechanics. The aiming down sights and aiming around cover has already been developed, so that just leaves me with a few other elements to complete this task on my negotiated brief.
To get started I drew some inspiration from Deus ex: Human revolution and created a laser sight particle system as a form of Meta UI. In Deus Ex, the laser sight replaces the standard UI crosshair, with an object that exists in the actual Gameworld. This is a good way to display information while keeping the player immersed.
Replicating this in my project involved, creating a sprite material, using it in a particle system and changing the settings to create a single particle with a glowing red colour. Setting the Alpha to greater than 1 causes the colour to appear this way.
I then added this particle effect to my character blueprint and changed its world location to a line trace impact point, projected from the barrel of the weapon. This location is updated on tick to show the exact point of aim.
I can also use this trace later on in the project to detect hit actors, when I start dealing damage to enemies.
Shooting and reloading
My weapon firing mechanic is quite basic at the moment. It performs checks to see if the player has ammo and is not currently in the middle of a reload. It then spawns a standard explosion emitter as a placeholder, to show where the round hits. later this will be where damage is dealt, depending on if I use projectiles or just the line trace.
The reload mechanic mechanic uses some integer variables for the magazine size, total ammo and current ammo to calculate how many shots can be fired. First there is a check to see if the magazine is not full, and there is spare ammo in the total to reload. Then it checks to see if the remaining space in the magazine will push the total below 0. If it will, then the remaining total ammo will be added to the magazine. If it wont then the magazine will be will be topped off to its max.
The reload also changes a "reloading" Bool to positive so that the player can't fire during the reloading cycle and I calls an event dispatcher, which I have set up in a user interface. When the dispatcher is called The user interface will display a progress bar to show the duration of the reload.
The progress bar is set up in a widget blueprint, to display a Float value using the delta seconds on tick. When the player reloads, the bar is set to visible and the value is increased when the reloading bool is set to positive.
Now that this is set up I can start implement damage to enemies, which will tie in nicely with the start of my AI