Add distance easing, so it doesn't jitter around too much when you're stuck.

This commit is contained in:
Sally Coolatta 2020-07-31 15:46:44 -04:00
parent 02e98c4d31
commit 7e7e56f0c6

View file

@ -7714,17 +7714,40 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
} }
// sets ideal cam pos // sets ideal cam pos
dist = camdist; {
const fixed_t speedthreshold = 48*mapobjectscale;
const fixed_t olddist = P_AproxDistance(mo->x - thiscam->x, mo->y - thiscam->y);
/* player->speed subtracts conveyors, janks up the camera */ fixed_t lag, distoffset;
speed = R_PointToDist2(0, 0, player->mo->momx, player->mo->momy);
if (speed > K_GetKartSpeed(player, false)) dist = camdist;
dist += 4*(speed - K_GetKartSpeed(player, false));
dist += abs(thiscam->momz)/4;
if (player->karthud[khud_boostcam]) if (player->karthud[khud_boostcam])
dist -= FixedMul(11*dist/16, player->karthud[khud_boostcam]); {
dist -= FixedMul(11*dist/16, player->karthud[khud_boostcam]);
}
speed = P_AproxDistance(P_AproxDistance(mo->momx, mo->momy), mo->momz / 16);
lag = FRACUNIT - ((FixedDiv(speed, speedthreshold) - FRACUNIT) * 2);
if (lag > FRACUNIT)
{
lag = FRACUNIT;
}
if (lag < camspeed)
{
lag = camspeed;
}
distoffset = dist - olddist;
dist = olddist + FixedMul(distoffset, lag);
if (dist < 0)
{
dist = 0;
}
}
if (mo->standingslope) if (mo->standingslope)
{ {
@ -8019,7 +8042,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
thiscam->momz = 0; thiscam->momz = 0;
} }
else if (player->exiting || timeover == 2) else if (player->exiting || timeover == 2)
{
thiscam->momx = thiscam->momy = thiscam->momz = 0; thiscam->momx = thiscam->momy = thiscam->momz = 0;
}
else if (leveltime < introtime) else if (leveltime < introtime)
{ {
thiscam->momx = FixedMul(x - thiscam->x, camspeed); thiscam->momx = FixedMul(x - thiscam->x, camspeed);