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