fix: jump fails in certain cases

This commit is contained in:
2026-03-14 18:00:02 +08:00
parent cf423c7db4
commit 7012e5f9fe
4 changed files with 6 additions and 5 deletions

View File

@@ -147,7 +147,7 @@ void Player::update(float delta_time) {
if (m_move_state.up) {
auto new_pos = m_player_pos + glm::vec3(0.0f, 1.0f, 0.0f) * speed * 2.0f;
new_pos.y += 2.0f;
if (!m_world.is_block(new_pos)) {
if (!m_world.is_block(glm::floor(new_pos))) {
new_pos.y -= 2.0f;
m_player_pos = new_pos;
}
@@ -185,7 +185,7 @@ void Player::update(float delta_time) {
static bool should_ceil = true;
if (!m_world.is_block(glm::floor(m_player_pos))) {
if (!m_world.is_block(glm::floor(m_player_pos)) && !m_move_state.up) {
m_player_pos -= glm::vec3(0.0f, 1.0f, 0.0f) * speed * 0.7f;
} else if (should_ceil) {