fix: ceiling collision prevents descent during jump

This commit is contained in:
2026-03-29 21:37:47 +08:00
parent fb11fee955
commit 53b56044b2
2 changed files with 8 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ private:
float m_speed = 4.5f;
float down_speed = 0.0f;
bool can_up = true;
float up_a = 0.0f;
float speed = 0;
glm::vec3 direction = glm::vec3(0.0f, 0.0f, 0.0f);
glm::vec3 move_distance {0.0f, 0.0f, 0.0f};

View File

@@ -284,7 +284,7 @@ void Player::update_move(float delta_time) {
update_direction();
move_distance = {direction.x * speed * delta_time, 0.0f, direction.z * speed * delta_time};
static float up_a = 0.0f;
static float y_a = 0.0f;
if (m_move_state.up && can_up) {
up_a = 100.f;
@@ -362,7 +362,12 @@ void Player::update_y_move() {
if (player_box.intersects(block_box)) {
m_player_pos.y -= move_distance.y;
down_speed = 0.0f;
can_up = true;
if (move_distance.y > 0) {
up_a = 0;
}
if (move_distance.y < 0) {
can_up = true;
}
return;
}
}