Spin car when steering

This commit is contained in:
Miloslav Ciz 2025-02-19 21:20:26 +01:00
parent def8fa3c27
commit ff3830cb02
2 changed files with 7 additions and 10 deletions

View file

@ -45,7 +45,7 @@
=========== BUGS =================
- the pinch collision test seems to sometimes stop the car e.g. after falling
from bigger height or when running into ramp at high speed - FIX
from bigger height or when running into ramp at high speed (or not?) - FIX
=========== HANDLED ==============

View file

@ -1344,18 +1344,15 @@ uint32_t LCR_racingStep(unsigned int input)
LCR_racing.carDrifting = 0;
}
/* The following fixes "sticking to a wall" issue by adding a small spin
to the car when trying to steer at very small velocity. */
if (steering &&
(input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK)) &&
(LCR_racing.wheelCollisions & 0x0f) &&
LCR_racingGetCarSpeedUnsigned() < (LCR_GAME_UNIT / 25))
(LCR_racing.wheelCollisions & 0x0f))
{
LCR_LOG2("spinning car a bit");
TPE_bodySpin(&LCR_racing.carBody,TPE_vec3(0,
steering == ((input & LCR_RACING_INPUT_LEFT) != 0) ?
TPE_F / 32 : -1 * TPE_F / 32,0));
/* When steering, also slightly spin the car. This helps fix the car
getting "stuck" by its side to a wall when too close, becoming unable
to unstick itself. */
TPE_bodySpin(&LCR_racing.carBody,_LCR_TPE_vec3DividePlain(carUp,
steering == ((input & LCR_RACING_INPUT_LEFT) != 0) ? 128 : -128));
}
}