I have attempted this before using setVelocity, if you had seen my [code fart] before:

The problem here is that setVelocity actually adds and subtracts from overall velocity of the tank so it actually give it more or less acceleration when it moves. The problem is with the amount of velocity needed. If I use small amounts of setVelocity, the recoil is barely visible, if I increase it, then there is a risk it will push tank too much.

So this time I revisited it with another idea. After figuring out how to obtain relative directional vectors, I made a function that would return relative directional vector of a vehicle's weapon. So the idea is if you reverse it, the vector you get is the vector of force of recoil. And indeed this works just fine:

What I did there was I temporary moved the centre of mass of the tank in the direction of recoil and then back. This visually creates push effect without affecting tank velocity. Funny thing is that the center of mass has to be offset from original center of mass exactly, otherwise tank can jet in the air like a rocket. Through the experimentation, it looks like it is better to leave centre of mass z unchanged as it makes tank more stable (damn PhysX). I also added a bit of a cam shake in 1st person for extra immersion. Here is the code to add to the init:

this addEventHandler ["Fired", format [" if (_this select 1 == '%1') then { _this = _this select 0; _recv = %2 vectorDiff (( _this worldToModelVisual (_this weaponDirection '%1') vectorDiff (_this worldToModelVisual [0, 0, 0]) ) vectorMultiply 1.2); _recv set [2, %3]; _this setCenterOfMass _recv; if (player in _this && cameraView == 'GUNNER') then { addCamShake [5, 0.5, 25]; }; _this spawn { uiSleep 0.2; _this setCenterOfMass %2; }; }", this weaponsTurret [0] select 0, getCenterOfMass this, getCenterOfMass this select 2 ]];

Not sure if it is MP compatible, probably not. Also kinda designed to work with MBTs only. Experimented with setting EH as string as well, so that all static values can be precalculated on EH creation and just embedded in the code.

Enjoy,
KK