Unstick car from walls
This commit is contained in:
parent
46efd97130
commit
b5cfda8253
1 changed files with 14 additions and 2 deletions
16
racing.h
16
racing.h
|
@ -806,8 +806,6 @@ printf("------\n");
|
|||
/* friction is in the direction if the axis and its magnitude is
|
||||
determined by the dot product (angle) of the axis and velocity */
|
||||
|
||||
|
||||
|
||||
TPE_Vec3 fric = TPE_vec3Times(ja,(TPE_vec3Dot(ja,jv) *
|
||||
_LCR_applyMaterialFactor(LCR_CAR_STEER_FRICTION,groundMat)) / TPE_F);
|
||||
|
||||
|
@ -817,6 +815,20 @@ printf("------\n");
|
|||
LCR_racing.carBody.joints[i].velocity[1] = jv.y;
|
||||
LCR_racing.carBody.joints[i].velocity[2] = jv.z;
|
||||
}
|
||||
|
||||
/* 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_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));
|
||||
}
|
||||
}
|
||||
|
||||
if ((!(input & LCR_RACING_INPUT_LEFT)) &&
|
||||
|
|
Loading…
Reference in a new issue