Add player_t.cameraOffset, offset chasecam Z position

This commit is contained in:
James R 2023-08-17 18:09:03 -07:00
parent 7f89bee3f2
commit ebb79fa34b
3 changed files with 7 additions and 2 deletions

View file

@ -504,6 +504,7 @@ struct player_t
fixed_t deltaviewheight;
// bounded/scaled total momentum.
fixed_t bob;
fixed_t cameraOffset;
skybox_t skybox;

View file

@ -7794,6 +7794,8 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
player->mo->spritexoffset = 0;
player->mo->spriteyoffset = 0;
player->cameraOffset = 0;
if (player->curshield == KSHIELD_TOP)
{
mobj_t *top = K_GetGardenTop(player);

View file

@ -3542,6 +3542,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
z = mo->z + pviewheight + distz;
}
z += player->cameraOffset;
// point viewed by the camera
// this point is just 64 unit forward the player
dist = 64*cameraScale;
@ -3586,13 +3588,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (mo->eflags & MFE_VERTICALFLIP)
{
angle = R_PointToAngle2(0, thiscam->z + thiscam->height, dist, mo->z + mo->height - player->mo->height);
angle = R_PointToAngle2(0, thiscam->z + thiscam->height, dist, mo->z + mo->height - player->mo->height + player->cameraOffset);
if (thiscam->pitch < ANGLE_180 && thiscam->pitch > angle)
angle += (thiscam->pitch - angle)/2;
}
else
{
angle = R_PointToAngle2(0, thiscam->z, dist, mo->z + player->mo->height);
angle = R_PointToAngle2(0, thiscam->z, dist, mo->z + player->mo->height + player->cameraOffset);
if (thiscam->pitch >= ANGLE_180 && thiscam->pitch < angle)
angle -= (angle - thiscam->pitch)/2;
}