Tweak jumping
This commit is contained in:
parent
4fdb59596f
commit
6cf6306b96
7
index.js
7
index.js
@ -147,8 +147,9 @@ function handleKeys(params) {
|
|||||||
params.camera.position[1] += 0.1;
|
params.camera.position[1] += 0.1;
|
||||||
} else {
|
} else {
|
||||||
if (params.jumpAmount > 0) {
|
if (params.jumpAmount > 0) {
|
||||||
params.camera.velocity[1] = 5.0 / 60;
|
const amount = 0.4 * params.jumpAmount;
|
||||||
params.jumpAmount -= 5.0;
|
params.camera.velocity[1] += amount / 60;
|
||||||
|
params.jumpAmount -= amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -190,7 +191,7 @@ function updatePhysics(params) {
|
|||||||
params.camera.position = newPos;
|
params.camera.position = newPos;
|
||||||
params.camera.velocity = newPos.map((v, i) => v - oldPos[i]);
|
params.camera.velocity = newPos.map((v, i) => v - oldPos[i]);
|
||||||
if (isOnGround) {
|
if (isOnGround) {
|
||||||
params.jumpAmount = 20;
|
params.jumpAmount = 6;
|
||||||
params.camera.velocity = params.camera.velocity.map(v => v * 0.7);
|
params.camera.velocity = params.camera.velocity.map(v => v * 0.7);
|
||||||
}
|
}
|
||||||
params.isOnGround = isOnGround;
|
params.isOnGround = isOnGround;
|
||||||
|
Loading…
Reference in New Issue
Block a user