Implement Wall Jumps in Unity

Mike Brisson
2 min readJun 21, 2021

We’ll be using the character controller for this method so let’s make sure that our movement is set up. We’ll need some variables like jump height, gravity and speed:

With our movement set, we now need to make sure that our character can perform a simple jump before we can wall jump.

We also want to lock horizontal velocity so that when the player jumps, they can’t change direction; Otherwise, the character controller won’t perform properly when wall jumping:

At this point, our charater should be performing like this:

With the groundwork complete, we are ready to add wall jumping. Unity has a built-in method called “OnControllerColliderHit()” that returns the collider of the object that was hit.

With this we can access the hit.normal which is the perpendicular direction of the face that was hit (drawn here in blue):

When the player is grounded, you see a vertical line, when it contacts the wall, you can see a horizontal line…both semming from the contact normal

We can use this information to jump in the direction of the face normal which will push us in the opposite direction of the wall. We also need to account for gravity so that we still jump upwards.

In the OnControllerColliderHit method, we need to make sure that the Object is ‘wall jumpable’ and keep track of the position of the hit:

With everything set up, we can now append our Jump() method to account for wall jumping:

--

--