Some tanks shoot themselves with the turret MG

Issue #403 resolved
Andrew Theel created an issue

Turret MGs in various Shermans (Stuart perhaps) shoot themselves when turret is at specific angles (usually to the left a bit). Fix should be adjusting the spawn location of turret MG projectiles. I'm not really sure what the issue is though. Even the MG sticking through the turret mantle looks a bit low and back.

2015-09-15_00021.jpg

Comments (10)

  1. Matt Hands

    The problem is the bullets hitting the part of the collision static mesh representing the driver's head - roughly spherical and always sticking up. That's why this occurs at around 11 o' clock. "Show collision" in console will

    Seems to affect M4A1 75mm, M4A3 75mm & M4A3 105mm. 76mm and jumbo turrets have a much higher coax position, so it clears the driver head collision. Stuart seems fine.

    Firefly is interesting, as it looks like it should suffer the same problem, but doesn't. Suspect FF's coax must simply have a bigger fire position offset, as Theel suggests, meaning its bullets clear the driver's collision. Fix is almost certainly to increase the fire position offset. In time I may remove the driver's head collision altogether, but that's for a future release.

    Different issue, but positioning of muzzle flash seems a little too high on 75mm and on Firefly too.

    Will fix all.

    NB - Position and protruding length of coax is a different, modelling issue, so I'm not going to deal with that here.

  2. Andrew Theel reporter

    Oh that's a shame I thought that little coax gun sticking out wasn't part of the model and was an "attached" thing that we could move around in code.

  3. Matt Hands

    Ouch ! Another fundamental bug/failing exposed - this time from UT2004.

    Increasing the AltFireOffset can solve the problem - but as well as moving the bullet spawn location forward, clearing the driver collision, it also moves the muzzle flash emitter forward. So on the 75mm turret this is not an acceptable solution, as it leaves the muzzle flash floating 2 feet in front of the coax MG.

    So why does it work ok on the Firefly? Because although the muzzle flash emitter only uses the AltFireOffset (logical), back in UT's VehicleWeapon.CalcWeaponFire() function, the WeaponFireLocation used to spawn the projectile applies the WeaponFireOffset as well as the AltFireOffset. That's not logical, at least not in a WWII tank turret, as the WeaponFireOffset is only about the cannon. The Firefly works by pure coincidence that it uses the turret's yaw bone as the fire bone, so it has a big X WeaponFireOffset, meaning it's coax bulllets also spawn way forward of the turret. While the 75mm Sherman uses the muzzle bone, meaning it has a much smaller X WeaponFireOffset, so its coax bullets spawn close to the MG and hit the driver collision.

    So to fix this I need to correct the original code deficiency and add some kind of separate X axis offset for the alt fire projectile spawn, which does not affect the offset used for the coax muzzle flash.

    EDIT - the coax MG is part of the turret model - a hull MG is an attached VehicleWeapon that could be repositioned in code. Yeah, shame.

  4. Andrew Theel reporter

    Perhaps just leave it alone for now. We can put this on hold and when we fix the driver collision boxes in a future update, this bug will no longer be valid.

  5. Colin Basnett

    I'm in agreement, the issue can be put on hold until the more permanent solution is devised (removal of player collision geometry in mesh).

  6. Matt Hands
    • changed status to open

    I've already done the fix ! :)

    Will commit soon.

    Needs something, as some vehicles have huge, unintended X offsets when spawning coaxial bullets, as they unwittingly apply big FireOffsets from the cannon.

  7. Matt Hands

    Fixed in commit 9a8c904.

    Added float AltFireSpawnOffsetX in DHVehicleCannon. Comment: "optional extra forward offset when spawning coaxial MG bullets, allowing them to clear potential collision with driver's head".

    Modified CalcWeaponFire() function to include any AltFireSpawnOffsetX for coaxial fire, and also removing the illogical addition of the WeaponFireOffset (shells) to alt fire.

    Included debug exec SetAltFireSpawnOffset for setting this new variable.

    Added to Sherman 75, 76, 105, Firefly, Panzer III ausf.L and Panzer IVs. Note some extra vehicles have been affected since removing the unwanted WeaponFireOffset.

    Experimented with each of these vehicle's coaxial MGs until I found exactly the setting of AltFireSpawnOffsetX that would just clear the driver's head collision. Then added 5.0 to be on the safe side, as the hit detection on the head collision doesn't seem entirely consistent.

  8. Matt Hands

    Note that although not directly related to this bug, in commits d3f4a1a and 3357840 I have:

    1. Made all cannons use their 'Barrel' bone (usually on or near the muzzle) for weapon fire positioning. Previously about a 50/50 mix of Barrel vs 'Gun' bone (pitch bone, much further back). Barrel bone feels more logical and the offsets make more sense. Either way, I wanted to standardise for consistency.

    2. Adjusted WeaponFireOffsets (shell launch position & muzzle flash) to adjust for new use of Barrel bone and to standardise offset positions, so are consistent across all cannons. I've adopted a standard of exactly 10 UU in front of muzzle for plain ended barrels, or directly on the muzzle tip for barrels with a muzzle brake (because flash is expanding in the muzzle brake and emitting sideways).

    3. Adjusted AltFireOffsets (coaxial MG) to adjust for new use of Barrel bone and to tweaked them all to position the flash exactly where it should be on the coax muzzle, or coming out of a hole in the mantlet.

    Note the jumbo is the only cannon that doesn't use its 'Barrel' bone for positioning weapon fire. That's because the barrel bone is very annoyingly rotated in the model, which screws it all up. So it's now the only cannon that uses the 'Gun' (pitch) bone for weapon fire positioning. I could fairly easily correct the bone rotation, but I'd have to re-make all the cannon anims.

  9. Log in to comment