Bohemia Interactive Forums  

Go Back   Bohemia Interactive Forums > BI MILITARY GAMES FORUMS > ARMA 2 EDITING > ArmA 2 & OA - MISSION EDITING & SCRIPTING

ArmA 2 & OA - MISSION EDITING & SCRIPTING For discussing the technical aspects of creating custom ArmA 2 & the standalone expansion Operation Arrowhead missions as well as scripting.

Reply
 
Thread Tools Display Modes
Old 11-04-2009, 01:51 PM   #1
afp
Sergeant
 
Join Date: Sep 2008
Posts: 159
Recoil uncovered (M16 recoil fixed)

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 this 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:



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.


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:
PHP Code:
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:
PHP Code:
TestAssaultRifleBase[] =         
{
    
0.000.00000.00
    
1.300.12000.00,
    
2.000.02000.20,
    
3.000.00000.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.





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

PHP Code:
TestAssaultRifleBase[] =  

    
0.000.00000.00
    
0.030.05000.00,
    
0.060.02000.05,
    
0.090.00000.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:




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



PHP Code:
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.030.05000.00,
                  
0.060.02000.05,
                  
0.090.00000.00};
};


class 
Mode_SemiAuto
{
    
recoil "TestAssaultRifleBase";
}


class 
cfgWeapons
{
    class 
RifleCore;

    class Default
    {        
        
recoil "TestAssaultRifleBase";
    }

    class 
RifleRifleCore
    
{        
        
recoil "TestAssaultRifleBase";
    }

    class 
M16_baseRifle
    
{
        class 
SingleMode_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):
PHP Code:
AK47_Recoil[]= {0,0,0,0.020.02000.0000,0.030.00000.0400,0.150.0000,-0.0020,0.150.00000.0000};
M16_Recoil[]=  {0,0,0,0.020.02000.0000,0.030.00000.0200,0.150.0000,-0.0010,0.150.00000.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:

PHP Code:
{
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

Last edited by afp; 11-08-2009 at 09:36 AM.
afp is offline   Reply With Quote
Old 11-04-2009, 06:00 PM   #2
galzohar
Warrant Officer
 
Join Date: Jun 2009
Posts: 2,933
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.
galzohar is offline   Reply With Quote
Old 11-04-2009, 07:26 PM   #3
afp
Sergeant
 
Join Date: Sep 2008
Posts: 159
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.
afp is offline   Reply With Quote
Old 11-04-2009, 11:34 PM   #4
Canukausiuka
Gunnery Sergeant
 
Canukausiuka's Avatar
 
Join Date: Jan 2007
Location: Huntsville, AL, USA
Posts: 442
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.
__________________

Formerly MSMS_KDXer (signed up January 2002)
Canukausiuka is offline   Reply With Quote
Old 11-22-2009, 11:14 PM   #5
Aries144
Private
 
Join Date: Nov 2009
Posts: 2
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.

Last edited by Aries144; 11-22-2009 at 11:16 PM.
Aries144 is offline   Reply With Quote
Old 04-23-2010, 10:25 PM   #6
Minoza
Staff Sergeant
 
Minoza's Avatar
 
Join Date: Aug 2009
Location: Zagreb
Posts: 272
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!
__________________
CPU: Phenom II 955 BE OC @3.6, GPU: HD 5870 OC @900/1300 + 9800GT Physx dedicated, DDR3: 2x2GB Kingmax 1600 7-7-7-24, MB: Gigabyte MA790XT, CPU Cooler: Arctic-Cooling Freezer 64 PRO, Case: Antec 300, PSU: Corsair 650W
Minoza is offline   Reply With Quote
Old 04-23-2010, 10:38 PM   #7
galzohar
Warrant Officer
 
Join Date: Jun 2009
Posts: 2,933
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.
galzohar is offline   Reply With Quote
Old 06-24-2010, 10:08 PM   #8
sommergemuese
Corporal
 
Join Date: Nov 2006
Posts: 66
Yeah! http://dev-heaven.net/issues/5653#change-55180
sommergemuese is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:33 AM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.