Final Project Week 3 - Bolt Recoil and Aiming



Last week I implemented the weapon stats and weapon switching into my system. This means that a lot of the core functionality of the system is in place.

This week I planned to only add the dynamic bolt recoil system, however it ended up taking a lot less time than I had planned, because of this I decided to start on next weeks task making the aim down sight system.

Dynamic Bolt Recoil

This week I created the dynamic bolt system that will match movement of the guns bolt with the rate of fire. This is to reduce the amount of animations needed for my system. I started creating parts of my system to reduce the reliance on animations in week 1. I want to do this because typically, one of the most challenging components in setting up a weapon system is animations, they take a long time to create, blending them together can sometimes prove challenging, and if you want to make a change to a weapon such as rate of fire, you would need to edit the animation to ensure the timing is correct, otherwise animations could get cut off because they dont match the timing of the system.

My original plan for the bolts movement was to use a unity move towards. this would mean that every time a shot was taken, the bolt would move towards its back position, then towards its front position, each movement would take half the cooldown between shots. The problem with this was how I had to create the system last week, originally I was going to make the shooting work a lot like that, however I had to change it to a system where multiple shots could fire each frame so that the experience is consistent over all different spec systems and with all different weapons.

To fix this issue I had to change how I looked at the system, the original idea included starting the movement as the shot happens, but what I actually have to do is calculate where it should be in its movement when the shot happens, this means that the first shot will start moving as the shot is taken, but if it takes less time than a single frame for enough time to pass for the next shot to fire, the bolt will be put in a different position for the next shot.

Example of a high rate of fire Example of a low rate of fire

Above you can see 2 examples of the system in use, the speed of the bolt is controlled by the fire rate making it extremely quick and easy to change the weapon. I think that the bolt system worked out well, it allows the user to set a custom forward and back position so that it will work with their weapons they create. This could also have other benefits aswell such as the ability to easily create attachments that can change the fire rate and have the visuals change accordingly.

The bolt system took a lot less time than I had expected, because of this I decided that I would make a start on the tasks I had planned for next week.

Aiming System

After deciding to move it to this week, I started work on the aiming system. To match the rest of my system, I want the aiming to be as flexible and modular. This means that I want the user to have control over the speed, positioning and rotation of the aiming. I also want all of these to be modified by different attachments.

I started by setting up the movement of the aiming. I wanted to have the system move the weapon between hip fire and aimed fire without an animation. I did this with a simple move towards, which will linearly move the weapon to the aimed position when the aim button is held, and back to the hip position when the aim button is released. The speed was controlled by a public variable so that the aim time can be set by the developer using the system.

Aiming using position Slower Movement

After setting up the positional aiming, I wanted to make sure the aiming system will allow for a rotational change aswell, the main reason for this is because it will allow the developers to align sights they have created properly, aswell as give an added effect if the developer feels it is nessasary for their game.

An example of rotation being used for aiming

Next I wanted to get the zooming working, this was fairly simple, I made it so that you put the zoom multiplication you would want, this measurement is used in the majority of games and in real life, so I decided to make my system work on that to make it as intuitive as possible. The default field of view (FOV) is then divided by that zoom amount, giving a zoom effect. Below are 3 different amounts of zoom being tested..

No Zoom 1.2x zoom 2x zoom

After getting this working I realised there was a syncing issue, where the weapon reaches the aiming position before the aiming rotation. There were 2 possible solutions to this issue, either find a way to make them always take the same amount of time, or have separate speeds for the rotation and position. I chose to keep 1 value that controlled the amount of time it takes to aim, rather than 2 values containing the speeds. I did this by getting the distance between the 2 points, dividing that by aim time then multiplying that by deltatime to ensure it is the same speed no matter what the frame rate. This works on the position aim and FOV.

No modifier on sway and weapon bob 50% sway and weapon bob

The last thing I did this week was create a multiplier that would change the amount of weapon bob and sway there is while aiming, This is to allow for greater accuracy while the player is aiming. The multiplier for weapon bob and sway are both individually customisable. In the future when modules are added, they could affect the multiplier to change the amount of movement there is.

This is everything I did this week, next week I will be continuing the aiming system specifically, adding idle sway, to mimic the in game characters breathing, and relative aim position, this will set the aiming position relative the weapons rotation so that different height sights can be added when attachments are implemented.

The GitHub for this project is available here: https://github.com/ElliotChester/Modular-Weapon-System-Final-Project

Comments