physics substeps calculation fix

This commit is contained in:
MihailRis 2023-12-10 21:50:52 +03:00
parent 2ba9125804
commit 00db63723a

View File

@ -69,12 +69,14 @@ void Player::update(
hitbox->velocity.z += dir.z * speed * delta * 9;
}
int substeps = (int)(delta * 1000);
substeps = std::min(100, std::max(0, substeps));
float vel = std::max(glm::length(hitbox->velocity * 0.25f), 1.0f);
int substeps = int(delta * vel * 1000);
substeps = std::min(100, std::max(1, substeps));
level->physics->step(level->chunks, hitbox,
delta, substeps,
crouch, flight ? 0.0f : 1.0f,
!noclip);
if (flight && hitbox->grounded) {
flight = false;
}