mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-04-10 06:14:07 +08:00
fix: ceiling collision prevents descent during jump
This commit is contained in:
@@ -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};
|
||||
|
||||
@@ -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;
|
||||
if (move_distance.y > 0) {
|
||||
up_a = 0;
|
||||
}
|
||||
if (move_distance.y < 0) {
|
||||
can_up = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user