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.

  • \$\begingroup\$ Are you sure that increasing 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\$ Aug 27, 2019 at 5:56
  • \$\begingroup\$ Would be great to know if you have solved your problem, and if so, how you solved your problem. \$\endgroup\$ Sep 10, 2019 at 5:35

2 Answers 2


You have to scale both the jumpVy and the gravity.

Explanation: jumpVy is the (upward) velocity of your character. If we never decrease this your character will fly away. Ok, so we decrease the velocity by using the gravity which pulls your character back to ground. Each iteration the upward velocity gets reduced by the gravity until it gets a downward velocity and your character start falling down. This is where your character is the highest (jump height). If you want to keep this point while increasing the speed you need to scale both forces. As your character is faster in his upward motion you need to slow him even further to get to the same point, your gravity value must be scaled by a bigger amount than the jump value.

Note: If your jumpVy and gravity have big values and your dt is high as well this might not work properly as the movement will be too fast or choppy, if this happens increase your sampling rate e.g. reduce the time between updating the positions and velocities.

You can find the working JSFiddle that is based on the post you linked here: http://jsfiddle.net/9opz3d0b/3/

I added a little red dot to show the highest point of the last jump.


Try this out and than change the scaleVY and scaleGravity back to 1.0 to see the difference.

Fast jump:

var scaleVY = 6.0;
var scaleGrav= 28.0;

Slow jump:

var scaleVY = 1.0;
var scaleGrav= 1.0;

I think its due the gravity. you are changing the value of jump but the gravity remain the same so impact of the gravity on both case is same so i suggest increase the value of the jump and reduce the value of gravity it would do the trick.

  • \$\begingroup\$ value of jump is a proportion of the gravity, so tweaking the values doesn't help. Even If I increase the jump it just goes higher, I want it to stay the same jump height while reaching there more quickly \$\endgroup\$
    – eguneys
    Aug 26, 2019 at 10:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .