From ea9d82104764efb0bc815263aa1102f460b8bffb Mon Sep 17 00:00:00 2001 From: paulaboks Date: Fri, 25 Sep 2026 17:30:52 -0300 Subject: [PATCH] Tweak gravity and jumping --- client/entity/entity.ts | 11 +++++++++-- client/entity/local_player.ts | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/client/entity/entity.ts b/client/entity/entity.ts index b0c00d9..4af2910 100644 --- a/client/entity/entity.ts +++ b/client/entity/entity.ts @@ -25,7 +25,11 @@ export abstract class Entity { width: number; height: number; eye_height: number; - gravity = -15.8; + // blocks per second squared + gravity = -32; + // what's left of its speed after each tick in the air, like minecraft's 0.98. it caps falling speed + // at 49 * -gravity * TICK_DELTA, 78 blocks per second with minecraft's gravity + drag = 0.98; // which way it hit something on each axis in the last move: 1 or -1, 0 for nothing. // 1 on y means it's standing on something @@ -70,11 +74,14 @@ export abstract class Entity { // one step of the game, TICK_DELTA seconds abstract tick(): void; - // falls and moves by its velocity for one tick, see move_body + // falls and moves by its velocity for one tick (see move_body), then slows down from drag move() { const collisions = move_body(this, this.gravity, (x, y, z) => this.level.has_collision(x, y, z)); this.colliding_x = collisions.x; this.colliding_y = collisions.y; this.colliding_z = collisions.z; + this.vx *= this.drag; + this.vy *= this.drag; + this.vz *= this.drag; } } diff --git a/client/entity/local_player.ts b/client/entity/local_player.ts index e0d21ef..36b1f4f 100644 --- a/client/entity/local_player.ts +++ b/client/entity/local_player.ts @@ -12,7 +12,8 @@ export class LocalPlayer extends Player { inventories = new ClientInventories(); move_speed = 4; - jump_force = 6.7; + // blocks per second, peaks about 1.25 blocks up with the entity's gravity and drag + jump_force = 9.23; #ticks_since_sent = 0;