Flak 38 shakes violently when being used

Issue #410 resolved
Colin Basnett created an issue

Comments (2)

  1. Matt Hands

    Fixed in commit cb0f486.

    I've been aware of this for a while and trying things out. It was an odd one, because the problem only really occurred in single player, not on a network (so it wasn't such a huge issue). And mostly a problem for the trailer version, although the static base version wasn't completely immune.

    I thought it was probably something to do with the collision box layout and was going to try different configurations. But after some experimentation this morning:

    It's a karma issue. In single player, enter console command "kstop" to toggle off karma and the problem ceases.

    Another SP console command "kdebugcontacts" writes karma contacts to the log. Watching in real time, every time any AT gun fires it logs a batch of "CONTACT: DH_Flak38Gun [WORLD TRIS]". The difference with the FlaK 38 is that it logs these karma contacts for a long time after firing, where other guns only do it for a split second. After maybe 20 secs, when the FlaK 38 sops shaking, the karma logging also stops.

    Firing tank cannons does not generate these karma contacts. I suppose either because the tank does not have a karma collision box in contact with the ground (it rides on physics wheels), or because the tank can move slightly to absorb the fire recoil, where an AT is static. Anyway, an aside,

    The problem is specifically caused by the gun's FireImpulse. Native firing code calls the ApplyFireImpulse() event, which applies any FireImpulse to the vehicle base by calling KAddImpulse() on it. And the karma impulse is added at the centre of mass - which is a good clue.

    The FlaK 38 cannon pawn extends the normal AT gun cannon pawn, so anything needed from the 234/1 cannon pawn has to be added. And the 234/1 has bHasFireImpulse=false. Because it's only a 20mm shell, but adding that line to the FlaK 38 is also an immediate fix to the fire shaking problem.

    I've also noticed that the gun will wobbble slightly when shot by small arms and, like the more violent fire shake, this lasts for a while before the gun stabilizes. I'm sure the bullet impact is also imparting a small karma impulse.

    So I concluded that the root problem was that the centre of mass is too high off the floor, especially for the trailer version (look in the editor on the animation tab and enable view karma). Combined with a low vehicle mass and 3 small collision box contacts on the ground, this allowed any karma impulse added at the COM to rock the gun too much. So I'll also lower the COM.

  2. Log in to comment