Create A Wall Jumping Mechanic In Unity

Assassin's Creed, Prince of Persia, Super Mario! All of these games have incorporated wall jumping in amazing ways. Maybe it’s just the ability to jump from wall to wall, or maybe it’s the ability to run partway up a wall and then vault yourself off and into a ledge grab or enemy tackle… No matter how you go about it, wall jumping is a fun and amazing mechanic to add to a game that can add challenge, tactics, and control to the player.

So let’s learn how to do it!

With my latest 2.5D Platformer game, I’m using a “Character Controller” component on my player so that’s how were gonna do this.

First, you’ll need to create a 3D player game object. This can be a primitive game object such as a capsue or cube. Add a “Character Controller” to it.

Next, you’ll need to create a new C# script and attatch it to your new player game object. This will control your player’s movement!

[Tip]

You can adjust your “_movementSpeed”, “_gravity”, and “_jumpHight” in the unity inspector untill it feels right to YOU.

The Character Controller has a built in function that allows you to check collisions similar to “OnTriggerEnter” called “OnControllerColliderHit”.

[Bonus Tip]

The “Debug.DrawRay” function I used there draws a line on your controller to show the direction of the noraml for the surface your touching.

A “normal” is a vector “perpendicular” to a surface at a particular point. “ControllerColliderhit.normal” will be the normal at the point of contact

[Important]

You can make walls by creating a couple primitive cubes and stretching them vertically. They should come with a non-trigger collider already attatched. Make sure to tag your wall objects so you’ll be able to reference them. I tagged my walls “Wall” as you can see in the script above.

And there you have it! The basics of creating wall jumping in your game!

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!