Jump to content
Sign in to follow this  
afp

Recoil uncovered (M16 recoil fixed)

Recommended Posts

Download demo addon

Overview

I was never happy about the ArmA default recoils that are a bit unrealistic and remove somehow the immersion from the game. Even more, I discovered that some mods using empiric values as the recoil parameters are not very well documented and kinda buggy. ACE added a bit of realism to recoils in ArmA1, the ones in Russian Federation Units (RHS) mod were even better. Still things could be improved so I decided to study it and make my own recoils. It was a nasty job, since I had to reload hundreds of times, so I also had to share this knowledge because its a daughting task for any modder.

Real recoils

The basics of this game is about fireing guns and this should be done as accurate possible. The real feeling is a combination of the following:

- loudness - you feel the sonic bang in your body - there are still sound mods having a drum sound as loud as the footstep sound...

- recoil - well, weapon do have recoils. For bigger weapons you might even need serious strength or

can happen:

- smoke and flash - you see and even smell them.

Lets check some real action first, I chose AK 47 for a bigger recoil:

<object width="560" height="340"><param name="movie" value="http://www.youtube.com/watch?v=ZCF_XoIlNSE&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/watch?v=ZCF_XoIlNSE&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>

As we can see, the real recoil motion of a gun looks quite complicated. The muzzle has a random movement after each fire, with a tendency of going up. The motion is not only in a vertical plan but we can consider this for simplification and because the game engine only simulates a vertical plan recoil. Also imagine that 5mm muzzle shift during shooting may represent 20m distance at target if looking to a scope attached to this weapon.

Things to consider

There are others things we have to consider. The game values for recoils refer to hundred parts of a second (0.05s) while the game runs at 30-60FPS, so the final recoil may be system power related - if you are a mod creator you better test the final version on a medium rig.

The recoil also depends on weapon caliber and stock caracteristics - a 7.62 bullet fired from an AK 47 will generate a higher and a different recoil than a M16 5.56 bullet. The bullet energy is different, 2000J vs 1600J for common 5.56mm. For reference I consider the M16 the default value, and the rest of them can be tunned around this value - AK higher values, M4 or some other foregrip weapons a bit smaller etc. They should still remain around this value as removing recoils makes the game fade and unrealistic.

Simulation of a recoil

As I said, the game engine only can simulate a verticale recoil. I have split the recoil in 3 separate movements, like in the picture bellow.

asda322424.jpg

In the first segment (0A), the weapons is going backward fast due to initial impulse of the fired bullet. This also should be visible in game as it creates some realistic effect of the weapon power. As the stock stops moving into the sholder, the muzzle rizes for a longer time (AB). While in point B, the attempt to re-zero the weapon by arm strength result in some extra timing. In the end, the weapon goes back a bit higher than original position to recreate the real recoil effect.

Well, at least this is what I tried to do, I got pretty close because of the limitations.

ArmA recoils

If we check into the config files, we find something like this:

recoil_single_primary_3outof10[] =
{
0.04,
"0.006*(	(3/7))",
"0.05*.5*(	(3/7))",
0.01,
"0.009*(	(3/7))",
0,
0.045,
0,
"-0.025*.5*(	(3/7))"
};

As some BIS developper stated in an older post, each array is composed of triplets (time, offset, angle), one after another(EDIT: it looks like its time-offset-offset). This also means that you can add as many triplets as you want, they will be parsed one after another. The point is that the test shown that offset in one triplet doesnt always have the same value as the one in another triplet, so everything should be tunned manually.

The attempt to create an extra timmimg with a triplet like {3s, 0, 0} failed, also I discovered that there is no point to add a rezeroing triplet as the engine (unlike ArmA1) brings the weapon in normal position and you cant move it a bit up. I bypassed this in the end by adding a last triplet who retarget the weapon slowly, like this: {0.09, 0.0000, 0.00};. I also had the impression that the first shot is a bit buggy, then the next ones do the suite correctly, also in scope mode the backward motion is not displayed right, like in ArmA 1.

I ended with this configuration for the simulated recoil, so I could see and study the real movement in slow motion:

TestAssaultRifleBase[] =         
{
   0.00, 0.0000, 0.00, 
   1.30, 0.1200, 0.00,
   2.00, 0.0200, 0.20,
   3.00, 0.0000, 0.00
};

As you can see, first tripplet is ignored. Then the muzzle goes backward for a short period (1.3 seconds), then it climbs for a longer distance. In the end, the muzzle re-zeros slowly, simulating the pause in B point earlier. Of course, everything is exagerated to see the movement better.

<object width="425" height="344"><param name="movie" value="http://www.youtube.com/watch?v=9u08YjPDkWo&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/watch?v=9u08YjPDkWo&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>

Translated in real values, this gives pretty realistic effect for an M16:

TestAssaultRifleBase[] =  
{ 
0.00, 0.0000, 0.00, 
0.03, 0.0500, 0.00,
0.06, 0.0200, 0.05,
0.09, 0.0000, 0.00
};

The effect can be increased by increasing angle in the third tripplet (0.05) up to 0.20 or so, or decreasing it a bit. The offset doesn't seems to have such a big effect in the third tripplet, but if you want to increase the backward distance you can do it with the offset in the second triplet (0.0500). Not much to change on timmings, if you find better combinations, just let me know. The difference is more visible and realistic in ACOG mode, where the scope effect is increased when a fire is shot.

The final result looks like this:

<object width="425" height="344"><param name="movie" value="http://www.youtube.com/watch?v=u98APuxaQjo&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/watch?v=u98APuxaQjo&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>

The full addon code is bellow, or you can download it as pbo here.

class CfgPatches
{
class TestRecoils
{
	units[] = { };
	weapons[] = { };
	requiredVersion = 0.1;
	requiredAddons[] = {"CAweapons", "CAData"};
};
};

class cfgRecoils
{
/*      test values:
TestAssaultRifleBase[] =  {0,0,0, 
			  1.30, 0.1200, 0.00,
			  2.00, 0.0200, 0.20,
			  3.00, 0.0000, 0.00}; 
*/
TestAssaultRifleBase[] =  {0,0,0, 
			  0.03, 0.0500, 0.00,
			  0.06, 0.0200, 0.05,
			  0.09, 0.0000, 0.00};
};


class Mode_SemiAuto
{
recoil = "TestAssaultRifleBase";
}


class cfgWeapons
{
class RifleCore;

class Default
{		
	recoil = "TestAssaultRifleBase";
}

class Rifle: RifleCore
{		
	recoil = "TestAssaultRifleBase";
}

class M16_base: Rifle
{
	class Single: Mode_SemiAuto
	{		
		recoil = "TestAssaultRifleBase";
	}
};
};

EDITED:

As in ArmA 1 the weapon does not zeros automatically, here is a nice strong recoil for it (we need to move towards zero before ending):

AK47_Recoil[]= {0,0,0,0.02, 0.0200, 0.0000,0.03, 0.0000, 0.0400,0.15, 0.0000,-0.0020,0.15, 0.0000, 0.0000};
M16_Recoil[]=  {0,0,0,0.02, 0.0200, 0.0000,0.03, 0.0000, 0.0200,0.15, 0.0000,-0.0010,0.15, 0.0000, 0.0000};

Conclusions

There are several problems with a realistic recoil in ArmA2, mainly because of some flaws in recoil parameters and game engine. The skeleton values provided here offer a good start to redesign all weapons recoils, while avoiding lot of testing.

EDIT: Here is another possible configuration, a bit better and more clear:

{
0,0,0,             // dummy, sometimes ignored
0.02,0.040,0,   // kickback - fast 
0.04,0,0.034,   // muzzle rising, still fast
0.15,0,-0.002, // top delay - slow
0.15,0,0          // recenter slowly
};

You can adjust the feeling with:

- recoil amplitude (muzzle 0.034) - range 0.004-0.070

- kickback length (0.040) - keep it in 0.010-0.050 range

- recentering time (delay and recenter 0.15) - range 0.10 - 0.20 for each

Edited by afp

Share this post


Link to post
Share on other sites

Looks like a nice idea. Is there any way to add any randomness to it? If not then unfortunately I don't see much point. If it is possible to add randomness then this can end up being pretty awesome, but will need a lot more work IMO. To get it to behave better you will need to give it more than just 3 movements so that the overall recoil action is smaller (fracture it into more, smaller movements, and the higher resolution will allow for smoother, more realistic movements).

Of course you will also need to do a weapon-by-weapon analysis, as different weapons recoil very differently. It's not just the recoil "amount" that is different. This is especially true for different action types (open bolt, bolt-action), but also just for different weapons of the same action type.

Anyway, if you can make this work then it'll be truly awesome, as this game desperately needs realistic recoil.

Share this post


Link to post
Share on other sites

I cannot figure out exactly but the engine may add a bit of randomness around the fixed points. While shooting in first person view in slow motion, it looks like the top point is not always the same, though not so far by the fixed point.

I'm sure the ACE guys will fix all recoils in their release, there are many others things to improve too.

Share this post


Link to post
Share on other sites

There is definitely a bit of randomness associated with each shot. A good recoil system would go a long way. I built the recoils for I44 as a simplified spring-damper system so that I would not be left trying to subjectively figure out what the recoils should be. It works okay, but it's far from optimized.

That's a great video of the AK firing, it does definitely show a backward then upward trend, which I may need to work on capturing in my physical model.

Also, does anyone have any idea what the influence of using string/code functions in the recoil is? I know that it works, but I can't tell if the engine properly interprets the code at startup or if it reinterprets it constantly at runtime.

Share this post


Link to post
Share on other sites

Just a quick note on that video guys: The shooter was not shouldering that AK properly. He has the stock too high and too far out from his centerline. As a result, the recoil you see in the video is going to be exagerated.

If the weapon is held with the stock on the upper right pectoral (for a righty), the whole rear of the stock in the shoulder, with nothing elevated above, the elbows tucked in, and the left hand with a more aggressive grip higher in relation to the boreline and farther out, the weapon won't bounce all over the place and twist like it did in the video.

Military folks who don't pay attention may shoot like that, but recoil won't look like that with the squared away guys shooting.

Do a search for Magpul Dynamics on Youtube and you should be able to find a slo-mo of a shooting instructor firing a rifle properly.

I don't shoot like that and I don't want my alter ego doing it in my game either. It's enough to give a shooter/instructor nightmares. :D

Edited by Aries144

Share this post


Link to post
Share on other sites

Will this be implemented in ACE? Cause afaik recoil in ACE atm is only based on vertical movement of barrel, or am I wrong?

I mean this looks awesome, seriously!

Share this post


Link to post
Share on other sites

This is a very old thread, I think the idea had been abandoned long ago... The recoil in ACE seems the same "shape" as in vanilla except the actual amount of recoil is greatly modified, at least for some weapons, though IMO for most weapons it isn't modified anywhere nearly enough for most weapons. Would definitely be nice to see ACE improve both the amount and the "shape" of recoil, and hopefully in a more detailed way than what was done in the first post.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×