jump climbing fix

This commit is contained in:
MihailRis 2024-01-27 01:24:56 +03:00
parent acacb88c66
commit 2580b9dc2f

View File

@ -25,7 +25,8 @@ void PhysicsSolver::step(
float dt = delta / float(substeps);
float linear_damping = hitbox->linear_damping;
float s = 2.0f/BLOCK_AABB_GRID;
bool prevGrounded = hitbox->grounded;
hitbox->grounded = false;
for (uint i = 0; i < substeps; i++) {
vec3& pos = hitbox->position;
@ -37,7 +38,7 @@ void PhysicsSolver::step(
vel += gravity * dt * gravityScale;
if (collisions) {
colisionCalc(chunks, hitbox, vel, pos, half,
(gravityScale > 0.0f) ? 0.5f : 0.0f);
(prevGrounded && gravityScale > 0.0f) ? 0.5f : 0.0f);
}
vel.x *= glm::max(0.0f, 1.0f - dt * linear_damping);
vel.z *= glm::max(0.0f, 1.0f - dt * linear_damping);