Tank treads can still be rotating even while tank is stationary

Issue #458 resolved
Colin Basnett created an issue

Reproduction steps:

  1. Player 1 drives a tank forward.
  2. Player 2 shoots the tank, killing the driver & the engine, but not blowing up the vehicle.

Players will observe the tank still have spinning treads with an accompanying sound.

Comments (5)

  1. Matt Hands

    It only happens when the shot disables the engine, as well as killing the driver (edited description to add that). Rare, which is why this isn't commonly seen. Can be reproduced with a temp code hack at the start of DHArmoredVehicle.TakeDamage() to kill the driver and engine, then exit the function. Now I know what causes it, I can fix.

    The problem stems from Tick, which updates tread movement, disabling itself at the end of the function if there is no driver and the vehicle isn't moving. In that situation it can't possibly move anywhere, so no need to keep Ticking. Tick is re-enabled when a player gets in again. You may think Tick is needed to update the exhaust effect if the engine is running, even if there is no driver, but the exhaust effect will have been set to minimum idle level and doesn't need updating until a player enters and the vehicle may be driven. Tick was originally disabled when the player exited, but that caused problems with dust emitters continuing, so now when the driver exits, we let the vehicle coast to a halt and then Tick disables itself.

    But, in a nutshell, the current sequence of relevant events in of Tick is: (1) update movement sounds & effects, based on current speed & throttle, (2) zero speed & throttle if engine off, (3) disable Tick if vehicle not moving and there's no driver.

    So if the engine is destroyed and the driver killed by the shot ...... Tick updates the track movement, then zeroes speed, then disables itself. Needs re-ordering so anything speed/throttle related comes before the block where the movement effects get updated. I'm doing it now.

  2. Matt Hands

    I have a pretty simple fix for this - as above - and will test and commit very soon. I think that will be Saturday now.

    I made the Tick() changes weeks ago & they solve the problem. I tried them out a bit in true multi-player, but wanted to run around in various vehicles a bit more, just to check for any unwanted effects. I never got time to do that with other more serious stuff, but give me a couple of days and I'll commit this.

  3. Matt Hands

    Fixes for tank sliding problems in commit d38d0a1 and commit a9e413et.

    Ended up removing Tick's messing with the value of the tank's WheelLatFrictionScale. Tanks have a default value of 3.0 and that works fine at any speed. ROTreadCraft added WLFS changes in Tick, with the comment "This will slow the tank way down when it tries to turn at high speeds". But it does nothing. Tanks slow down when turning at high speeds anyway, I think due to karma property KMaxAngularSpeed (certainly one of the karma props anyway). This also saves the server from having to do any velocity-related calculations many times per second, which is an added bonus.

  4. Log in to comment