I've applied this method How to make a character jump?, like:
let wallForce = 0;
const targetVx = -gravity * 4.0;
const updatePos = delta => {
const dt = delta * 0.01;
const oldY = hero.y;
hero.vy += wallForce * dt;
hero.vy += gravity * dt;
hero.x += hero.vx * dt;
hero.y += hero.vy * dt;
updateCollisionsBetween(oldY, hero.y);
hero.vx += (targetVx - hero.vx) * dt;
wallForce = 0;
};
and on jump:
let doubleJump = 0;
const jump = delta => {
wallForce = 0;
hero.vy = -hero.jumpVy;
if (doubleJump === 1) {
hero.vx *= 2;
}
};
I want to speed up the jumps, that is I want the hero to jump and land faster. If I give a higher negative velocity on the jump (eg. hero.vy = -hero.jumpVy * 2.0
), then the hero jumps higher but its speed doesn't change.
jumpVy
does not change the speed in the Y-Direction of your character? From the code given your character should jump to a higher position in the same amount of time as before scaling, thus jump faster and higher at the same time. Could you check this and report back? \$\endgroup\$ – Mailerdaimon Aug 27 at 5:56