How to add wall jumping to platformer in Unity

Niklas Bergstrand
2 min readJun 13, 2021

--

Let’s go over how to add to add wall jumping to the platformer controls.

The first part of the platformer controls was added in this article.

Select the wall objects and set the tag to Wall:

Open up the Player script and add two more variables - a bool to check if the player can wall jump, and the direction of the surface normal (the visible face of the geometry):

Add the function OnControllerColliderHit which takes in the collision information from the Character Controller. If the player is not standing on the ground and is touching a wall object set _canWallJump to true and also set _wallSurfaceNormal to the normal of the colliding wall:

For the player movement, remove the ability to control the player in the air by moving horizontalInput, _direction and _velocity inside the if statement. If the player is not on the ground and is touching the wall set the main velocity to _wallSurfaceNormal and set yVelocity to _jumpHeight.

Good luck!

--

--

Niklas Bergstrand
Niklas Bergstrand

No responses yet