add core:mob component & move player movement to scripting

This commit is contained in:
MihailRis
2025-08-10 22:55:34 +03:00
parent 67ef84d6b0
commit dfb83f6835
10 changed files with 132 additions and 100 deletions
+4 -4
View File
@@ -25,7 +25,7 @@ void PhysicsSolver::step(
entityid_t entity
) {
float dt = delta / static_cast<float>(substeps);
float linearDamping = hitbox.linearDamping;
float linearDamping = hitbox.linearDamping * hitbox.friction;
float s = 2.0f/BLOCK_AABB_GRID;
const glm::vec3& half = hitbox.halfsize;
@@ -45,11 +45,11 @@ void PhysicsSolver::step(
colisionCalc(chunks, hitbox, vel, pos, half,
(prevGrounded && gravityScale > 0.0f) ? 0.5f : 0.0f);
}
vel.x *= glm::max(0.0f, 1.0f - dt * linearDamping);
vel.x /= 1.0f + dt * linearDamping;
vel.z /= 1.0f + dt * linearDamping;
if (hitbox.verticalDamping) {
vel.y *= glm::max(0.0f, 1.0f - dt * linearDamping);
vel.y /= 1.0f + dt * linearDamping;
}
vel.z *= glm::max(0.0f, 1.0f - dt * linearDamping);
pos += vel * dt + gravity * gravityScale * dt * dt * 0.5f;
if (hitbox.grounded && pos.y < py) {