Wall Jumping In Unity

Wall jumping! I literally get excited about this. The first game comes to my mind about wall jumping is SpeedRunners, which I am a huge fan. If you have a small group of friends, I suggest you to take a look at this game.

Another day, and new things were learned! As we move up with the elevator, the next challenge for the player is to climb to a high wall — using wall jumping. The aim is to climb to upwards by jumping in between the two walls.

This article will focus on creating the wall jumpin functionality.

So how will we detect that we are colliding with a wall? And how are we going to make the player jump in the opposite direction?

Character Collider has a ready method of OnControllerColliderHit that we can use in this case.

From Unity Manual

As an example to observe it’s functionality, let’s draw a ray.

private void OnControllerColliderHit(ControllerColliderHit hit){Debug.DrawRay(hit.point, hit.normal, Color.blue);}

Here’s a close shot that you can observe the rays.

Just like on the standard collision/trigger detections, we can get further information about the surface we have hit on the ControllerColliderHit class.

ControllerColliderHit — from Unity Manual

To make the player to be able to jump at the wall, we first need to detect that Player is touching the wall and is not grounded. To determine the walls, I have tagged the corresponding walls with “Wall” tag. Now, our player will know once he/she is touching them.

Before beginning, to check if our system will work, you can simply add a debug.log :

Now, we need to add the functionality for the wall jump. There is a need to define a new bool variable which will return true once we are touching the wall, so that the Player jumping movement will implemented accordingly.

In the OnControllerColliderHit method, hit.normal returns a Vector3 variable which is perpendicular to the surface we have hit. Which will be useful in this case. Define a Vector3 variable of wallSurfaceNormal which will be equal to hit.normal once we hit the wall.

Here’s the relevant shots from the scripts:

We basicly disable the wall jump once we are grounded and enable it once we touch the wall. Certainly, you can play with the variables according to your desire.




Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AusHomeLife — My very first Salesforce build as an SF Admin in training (Part 1C).

What’s the best Headless CMS?

Flutter | Jumping dots progress indicator

Project 2 Sinatra Web Application

Blogs: Week of 24 Jan — 30 Jan

Are you cloud native?

Building a CSS game without HTML or JS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ali Emre Onur

Ali Emre Onur

Unity Developer

More from Medium

3rd Person Follow Virtual Camera Explained in Unity’s Cinemachine

Unity Profiler- Game Dev Series 144

Pushing Objects in Unity to Complete Puzzles

High Definition Render Pipeline in Unity