Primitive Recoil System

Hello! I was following an tutorial to get more experience on some functions and decided to make my own recoil system. It is a lot primitive yet, i don’t have much time but i’m implementing.

All done using C++, but in the editor you can edit: Fire rate, recoil strength, recoil direction and the time to reset recoil.

Some primary rules on the system:

If you have stopped to shoot, quickly changed your target and started to shoot again before the reset time has finished, the recoil will follow your previous spray. So you need to wait the time becomes zero to shoot again with the recoil going only up. (Like in the video.)

You can hold the left mouse button to get a automatic shoot, but if you click every time, only will fire agreeding your fire rate. (First example in video)

Pistol doesn’t have the automatic function, if you hold the button, will shoot one time and nothing more. You have to click. (Only will shoot agreeding your fire rate²)

If you think that can be more “randomized”, the idea its more skill and less luck, on the video, the recoil strength is not much but i can’t control perfectly, it’s linear but if you try to control, becomes randomized. The game i’m planning don’t have too much close distances, so, the strength don’t need to be so high.

Edit: The change of direction is much accentuated for debug reasons. You can make it softly.

Due the “needs to be more randomized” advices, i decided to add randomized shoots after the “up” recoil. Thinking if i should to do randomized for up too…

Random Value = 3.0;

Softly random value after “up” recoil. The first bullets its not randomized, because, that’s a recoil mechanic. If you are not moving yourself or not shoting all the time, why the bullet needs to be randomized? You are aiming. The first bullets are not randomized, because that’s a recoil mechanic. If you are not moving yourself or shooting all the time, why bullet needs to be randomized? You are aiming.

So, a more complete video with a little difference. Difference is: Now, theres also a random stage with the recoil going up, to give a less robotic aim.