mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'natural-camera-outrun' into 'master'
Add distance easing to the camera, so it doesn't jitter around too much when you're stuck. See merge request KartKrew/Kart!310
This commit is contained in:
commit
57e69603a4
1 changed files with 33 additions and 8 deletions
41
src/p_user.c
41
src/p_user.c
|
|
@ -3181,17 +3181,40 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
}
|
||||
|
||||
// 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 */
|
||||
speed = R_PointToDist2(0, 0, player->mo->momx, player->mo->momy);
|
||||
fixed_t lag, distoffset;
|
||||
|
||||
if (speed > K_GetKartSpeed(player, false))
|
||||
dist += 4*(speed - K_GetKartSpeed(player, false));
|
||||
dist += abs(thiscam->momz)/4;
|
||||
dist = camdist;
|
||||
|
||||
if (player->karthud[khud_boostcam])
|
||||
dist -= FixedMul(11*dist/16, player->karthud[khud_boostcam]);
|
||||
if (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)
|
||||
{
|
||||
|
|
@ -3480,7 +3503,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
thiscam->momz = 0;
|
||||
}
|
||||
else if (player->exiting || timeover == 2)
|
||||
{
|
||||
thiscam->momx = thiscam->momy = thiscam->momz = 0;
|
||||
}
|
||||
else if (leveltime < introtime)
|
||||
{
|
||||
thiscam->momx = FixedMul(x - thiscam->x, camspeed);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue