From e07a51c9d9d657f73e5db6bcbee7f392aedfd498 Mon Sep 17 00:00:00 2001 From: ITR Date: Mon, 9 Sep 2024 22:41:12 +0200 Subject: [PATCH] Was accidentally checking against steppingHeight instead of height. Fixes #703 --- src/game.zig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/game.zig b/src/game.zig index 8e1443e8..0596cb44 100644 --- a/src/game.zig +++ b/src/game.zig @@ -286,13 +286,14 @@ pub const collision = struct { checkPos[index] += amount; if (collision.collides(side, dir, -amount, checkPos, hitBox)) |box| { - const height = box.max[2] - checkPos[2] + hitBox.max[2]; - if (height <= steppingHeight) { + const newFloor = box.max[2] + hitBox.max[2]; + const heightDifference = newFloor - checkPos[2]; + if (heightDifference <= steppingHeight) { // If we collide but might be able to step up - checkPos[2] += steppingHeight; + checkPos[2] = newFloor + 0.0001; if (collision.collides(side, dir, -amount, checkPos, hitBox) == null) { // If there's no new collision then we can execute the step-up - resultingMovement[2] = height; + resultingMovement[2] = heightDifference; return resultingMovement; } }