# WallJump Helper - How to lerp player position towards future trajectory position

Hello guys,
Here is the pitch, stay with me !

I’ve learn all the basics about 2D walljumps, and my implementation actually works.
I’m trying to polish the player control and inputs and I’d like to create a “helper” for the walljump.

“A Helper ? What the hell are you talking about ?”

• Well, right now, there is a dilemma :

1/ The wall detection is commonly narrow, it lets the player jump off the wall if the player is in contact with the wall, so if the input is not too soon. All good, except you can have a sense of missed input if you anticipate the wall contact too much.
2/ The wall detection is more permissive but then the player is able to kind jump in “mid air”, BEFORE he actually touches the wall.

So I came up with a “solution”.
The wall detection is larger, like in 2 above, but if there is an input for the wall jump in range, the controls are disabled and the player is “pushed” towards the wall, once it gets in contact, the jump is actually performed and the controls are back again.

It works kinda nice, but also kinda “jerky” : the player jump is interrupted in “mid air” to go towards the wall
→ The parabolic jump movement becomes just a translation on the X axis, it feels unnatural.

What I’d like to achieve then, is some thing more like this :

It goes beyond my modest knowledge so if someone brilliant here can come up with something, may he be blessed

Thanks guys

Smoothing movement between any two particular values:

You have currentQuantity and desiredQuantity.

• only set desiredQuantity
• the code always moves currentQuantity towards desiredQuantity
• read currentQuantity for the smoothed value

Works for floats, Vectors, Colors, Quaternions, anything continuous or lerp-able.

The code: SmoothMovement.cs · GitHub

1 Like

Hey Kurt, thanks for helping.

The thing is I actually haven’t ! I have current quantity but my problem is not the lerp, it’s finding the “desiredQuantity”.
I don’t know how to extrapolate the parabol towards the wall to find the intersection position ! =)

[EDIT]
Damn, it looks like a differential equation or am I too old ?!

That’s beyond my actual experience but if my boss said “make it so I can run on walls!” then I would do this:

• go watch 2 or 3 tutorials to see how they do it

• OR… if I had no internet:
– try raycasting to the left/right a short distance to sense the wall
– when you find the wall, the target becomes the hitpoints’ contact
– activate the wall running code until it ends
– switch back to regular

1 Like

I think my explanation was bad, I’ll try to explain better.

What you suggest is actually what I already do : raycast at close distance, and the hit point becomes the target, then i lerp the player there. It does work… but !

The thing is when you are “mid-jump”, it feels weird to interrupt the parabolic movement to suddenly move the player in a translation move.
Here is the image modified to illustrate better :

Blue position is what I currently do, and also what you were suggested.
Red position is what I’d like to target to avoid the jump movement to be “cut”

=)

Again, I’m out of my depth here… you’re gonna have to get some video of 2D wall jumps and try to figure out what is going on.

If the player is already on the way to the wall, why do you need to override their movement? Can you not just wait for them to hit the wall?

1 Like

You mean registering the input early but wait for the collision to make the jump ? I thought about that but decided it would feel laggy…bi might be wrong though.

Ultimately I almost try to fastforward time once I accept the early input. Then quickly get the character in position to walljump and make it feel fluid

This is more of a physics question than a game programming one. Since you know initial velocity, distance, and acceleration, you can find delta y by using kinematics equations.

First, assuming your x velocity is constant while in the air, find time by distance over velocity:

`time = x_distance / x_velocity`

Then, delta y can be calculated as:

`delta y = initial_y_velocity * time + 1/2 * y_acceleration * time^2`

y acceleration in this case is your gravity.

2 Likes

Sounds good to me
I ll give it a try tonight, thanks

1 Like