# 2d – What are the parameters for a smooth wall jump

I want to make a platformer like Celeste and trying to implement wall jump.
When the player is on the air and near a wall, and presses jump, the player gains x velocity opposite the wall direction, and some y velocity. So the player jumps against the wall, but it shouldn’t climb the wall thru wall jumping.

Game runs 60 frames per second. resolution is 320×180. Tile size is 16.
Here’s some constants for calculating velocity and gravity:

``````export const vMax = 4; // maximum velocity in pixels
export const tMax = 20; // time to reach maximum velocity in frames

export const hMax = 16 * 3; // maximum jump height
export const xSubH = 16 * 3; // x distance that is reached in one jump

export const xFriction = 5 / tMax;  // friction to apply to x velocity
export const hAccel = vMax * xFriction; // accelaration for x

export const v0Jump = (2 * hMax) * vMax / xSubH; // initial jump velocity
export const gJump = - (2 * hMax * vMax * vMax) /
(xSubH * xSubH); // gravity applied to y velocity on jump
``````

Here’s how I do wall jump:

`````` // player object
let p = {
x: 0, // position
y: 0,
dx: 0, // velocity
dy: 0,
ax: 0, // acceleration
ay: 0
};

// let inputX = -1 for left input 1 for right input

// x movement
let _hAccel = inputX * hAccel;
p.dx += _hAccel;
p.dx += - p.dx * xFriction;

// let isGrounded = ...
// let wallDir = ... // -1 for left wall 1 for right wall

// fall
if (!isGrounded) {
p.ay = -gJump;
}

// jump
p.ay = -gJump;
p.dy = -v0Jump;

// wall jump
p.dy = -v0Jump;
p.dx = - wallDir * hAccel;

p.dy += p.ay;

// position
p.x += p.dy;
p.y += p.dx;
``````

What are the parameters of the wall jump I need to control and tweak so it looks smooth and doesn’t allow player to climb up the wall. But player can climb two walls side by side jumping one off another vs.

As you can see I have parameters like `vMax` and `tMax` that I can tweak to control the jump and movement. I tried setting arbitrary fractions of current values to give more x velocity or y velocity for wall jumping, but I can’t quite get a wall jump that feels good to climb against two walls.

If you look at the Celeste Pico 8 source code:

``````  if (E.abs(spd.X) > maxrun)
spd.X = G.appr(spd.X, E.sign(spd.X) * maxrun, deccel);
else
spd.X = G.appr(spd.X, input * maxrun, accel);
``````

When the x velocity is greater than maxrun, it is decelarated towards maxrun, otherwise it is decelarated towards input. So this basically disables input when given a big x velocity, thus disallowing to approach the wall thru input.