update entities physics & fix jumping mobs

This commit is contained in:
MihailRis
2025-09-07 15:07:39 +03:00
parent 93e7ae159a
commit 67a5741ed2
3 changed files with 21 additions and 12 deletions
+6 -5
View File
@@ -45,11 +45,6 @@ void PhysicsSolver::step(
colisionCalc(chunks, hitbox, vel, pos, half,
(prevGrounded && gravityScale > 0.0f) ? 0.5f : 0.0f);
}
vel.x /= 1.0f + dt * linearDamping;
vel.z /= 1.0f + dt * linearDamping;
if (hitbox.verticalDamping) {
vel.y /= 1.0f + dt * linearDamping;
}
pos += vel * dt + gravity * gravityScale * dt * dt * 0.5f;
if (hitbox.grounded && pos.y < py) {
@@ -89,6 +84,12 @@ void PhysicsSolver::step(
hitbox.grounded = true;
}
}
vel.x /= 1.0f + delta * linearDamping;
vel.z /= 1.0f + delta * linearDamping;
if (hitbox.verticalDamping) {
vel.y /= 1.0f + delta * linearDamping;
}
AABB aabb;
aabb.a = hitbox.position - hitbox.halfsize;
aabb.b = hitbox.position + hitbox.halfsize;