Final Project Week 10 & 11 - Completing Recoil
In week 9, I implemented the basic functionality of recoil. My goals for week 10 and 11 were to complete the recoil mechanics and apply it to the hip fire. Completing the recoil took longer than expected, however applying it to hipfire was a lot easier than I thought it would be. Because of this, I am compiling both weeks into this single blog post.
Research
I started the completion of recoil by looking more into how other games handle theirs. I looked at the same 3 games that I looked at in week 9, Battlefield V, Apex Legends and Rainbow Six Siege. Last week I focused on the games core implementation of recoil, the speed and direction they travel, as well as how they handle input, but one part that I didn't think about before, is how they handle returning to centre, so I looked at that this week.The implementation of returning to the centre is almost identical in all three games that I tested. Because of this, I have a clear vision of how I want to move forward with my system. I will briefly talk about how they handle it.
All 3 games handle returning to centre the same way, but with slight variations. You can see that as soon as the recoil has finished, it immediately begins returning to the centre. I looked at how the centre is changed based on user input last week. The main variations between the games is actually a variation between different weapons withing the games also, and this is the speed of the return. This is most likely used to balance different weapons and give a sense of weight to heavier or lighter weapons.
![]() |
![]() |
![]() |
Apex Legends Returning to centre | Rainbow Six Siege Returning to centre | Battlefield V Returning to centre |
One thing that I did notice within the games is that some guns appear to have acceleration with their return, this is something that I don't feel is essential so I don't plan to implement it yet, however if I get some extra time towards the end of the project it might be nice to have as a stretch goal.
Implementing Return To Centre
Now that I had a good idea of what I wanted to implement into my system I started working on returning to the centre after shooting. At this point, the way the system worked was by adding the amount of recoil onto the rotation directly. This was ok when you didn't need to remember how much recoil had been added, but now I need the system to remember how much recoil has been added so that it can return to the centre.Adding Core Functionality
To calculate where to return to, the mouse look system has 2 values within it, the mouse movement rotation, and the recoil rotation. The mouse look direction is set as the mouse rotation plus the recoil rotation every frame, this allows me to know exactly how much recoil has been added at any given point. With this now in place, I was able to have the recoil return to the centre while no shooting is happening. I have given it its own value for the speed of returning, however, this may change with playtesting, I am not sure whether I will leave it as it is or change it to a set amount of time that will be the same no matter how far you have to return. I am set to finish all of my milestones earlier than expected so I may return to this in a few weeks and add the ability to do both. If I have time towards the end of the project, I would also like to add smoothing much like battlefield has that will allow the user to set a start speed end speed and acceleration. however, I did not have time to implement it this week.![]() |
![]() |
Recoil without returning to centre | Recoil with the return to centre implemented |
Handling Input Correctly
The clip below shows an issue that I had with the recoil returning. If the user looked down while shooting to compensate for recoil, the system would then return them to a point much lower than they began. I knew that this would be an issue, so I was already thinking about how to fix this while planning the two look rotations I talked about before. The solution I found for this will change how the system reacts to the mouse input. The new method will work normally for horizontal or upwards mouse movement so it will add it directly to the mouselook rotation. The change is added to the y-axis of the mouse. If the recoil rotations x-axis is over 0, it will take the mouse y-axis from the recoils x-axis, but if the recoils x-axis goes below 0 and the mouse y-axis is below 0, it will set the recoil x-axis to 0 and apply the mouse movement to the mouse look rotation. This method is also applied to downwards recoil.![]() |
![]() |
Without correct input handling, it returns to the wrong place | With correct Input handling, recoil returns to where the user would expect |
Ensuring Player Control
My goal is to ensure that the user always feels like they have control of the gun and the recoil. There was 1 last major problem that was causing a lack of control with the recoil. As the gun was returning, it would continue to return even if the user moves the mouse, this made it feel like the user was fighting against the system. This is desired when shooting, and recoil is being applied, but after the shooting has ended I want the user to be able to have full control. This was an easy fix. I set it so that if the user moves the mouse while returning, the recoil rotation will be added to the mouselook rotation and the recoil rotation is set to 0. This means that it stops returning immediately and the user regains full control over the system.Receiving Feedback
I posted a video of my system on Twitter, I received some feedback from another user. They mentioned that they felt that the gun looked very locked in place on the screen as if the camera was moving not the gun, this is exactly what is happening, but I can see why they may feel that this is a problem. My system is intended to be used by a wide variety of people, so I want to make sure that I take all feedback seriously and implement as many suggestions as possible to allow for the best system possible. I have an idea of how I can implement the suggestion that the user wanted, however, it is not a priority for now as I have run out of time for these 2 weeks to continue working on the recoil. I will try and implement this feature in the final weeks of the project as I should have some time to spare.Implementing Hip Fire Recoil
The added features of the recoil system took me 10 days so to finish off the second week I applied the recoil functionality to hipfire. This was a lot easier to implement than I had expected. I thought that I would have had to have a unique set of functions and variables for hipfire, however, after giving it some thought I decided that the best way to handle it would be to have a multiplier for the speed and hipfire amount.There were some changes that I had to make to the method I had previously used. For aimed fire, the system uses the position of the reticle to calculate the next point. But for hip fire, the reticle is not close to the centre of the screen so it caused an issue where the recoil would move in completely the wrong direction. This was fixed by having hip fire calculate the next recoil position from the centre of the screen, rather than the reticle, this allows the system to correctly calculate the recoil for hip fire.
![]() |
![]() |
![]() |
0% Hip Fire Recoil | 50% Hip Fire Recoil | 100% Hip Fire Recoil |
Next week I will be working on implementing attachments into the system that will affect multiple variables of the weapons.
You can find the project on GitHub here: https://github.com/ElliotChester/Modular-Weapon-System-Final-Project
References
Battlefield V. 2018. PC [Game]. EA DiceApex Legends. 2019. PC [Game]. Respawn Entertainment
Rainbow Six Siege. 2015. PC [Game]. Ubisoft
Comments
Post a Comment