From 85eaf2eeeac2c65f28f273bae0eddf733e8c0132 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 23 Apr 2023 14:51:29 -0400 Subject: [PATCH] Make camera follow platform momentum --- src/p_local.h | 1 + src/p_mobj.c | 4 ++-- src/p_user.c | 16 +++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index aba75cbb8..ddb01d565 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -121,6 +121,7 @@ struct camera_t // Momentums, used to update position. fixed_t momx, momy, momz; + fixed_t pmomz; // SRB2Kart: camera pans while drifting fixed_t pan; diff --git a/src/p_mobj.c b/src/p_mobj.c index af2394298..4cf846b5c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3885,10 +3885,10 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled thiscam->floorz = tm.floorz; thiscam->ceilingz = tm.ceilingz; - if (thiscam->momz || player->mo->pmomz) + if (thiscam->momz || thiscam->pmomz) { // adjust height - thiscam->z += thiscam->momz + player->mo->pmomz; + thiscam->z += thiscam->momz + thiscam->pmomz; } if (thiscam->ceilingz - thiscam->z < thiscam->height diff --git a/src/p_user.c b/src/p_user.c index f67ef1294..89975251e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2549,9 +2549,6 @@ void P_MovePlayer(player_t *player) // Look for Quicksand! if (CheckForQuicksand) P_CheckQuicksand(player); - - if (P_IsObjectOnGround(player->mo)) - player->mo->pmomz = 0; } static void P_DoZoomTube(player_t *player) @@ -4545,9 +4542,6 @@ void P_PlayerAfterThink(player_t *player) player->mo->flags |= MF_NOGRAVITY; } - if (P_IsObjectOnGround(player->mo)) - player->mo->pmomz = 0; - K_KartPlayerAfterThink(player); if (player->followmobj && (player->spectator || player->mo->health <= 0 || player->followmobj->type != player->followitem)) @@ -4598,11 +4592,19 @@ void P_PlayerAfterThink(player_t *player) player->timeshit = 0; } - if (K_PlayerUsesBotMovement(player)) { K_UpdateBotGameplayVars(player); } + + if (thiscam) + { + // Store before it gets 0'd out + thiscam->pmomz = player->mo->pmomz; + } + + if (P_IsObjectOnGround(player->mo)) + player->mo->pmomz = 0; } void P_SetPlayerAngle(player_t *player, angle_t angle)