Wall Jumping in Unity

Roger moore
2 min readJul 27, 2023

--

Objective: add wall jumping to the platformer

In our 2.5D platformer, we want to add an exciting wall jumping mechanic that allows the player to rebound off walls for more dynamic gameplay. To achieve this, we’ll detect when the player collides with a wall, enable wall jumping, and adjust the movement logic accordingly. Let’s dive into the implementation of wall jumping and elevate our platformer experience!

To enable wall jumping, we need to tag the walls in our scene with the “Wall” tag. This will help us identify the colliding surfaces that the player can jump off.

We’ll use the OnControllerColliderHit method to detect wall collisions when the player is not grounded (i.e., in the air). When a wall is detected, we'll set a flag _wallJumping to true and store the wall's normal direction in _wallJumpDirection.

Next, we’ll update our movement method to handle wall jumping differently. If the player is grounded, we’ll move horizontally using the input as before. Otherwise, we’ll handle the vertical movement, which includes wall jumping behavior.

Now, we’ll implement the wall jumping logic in the HandleJump method. When the jump input is detected and the player is allowed to jump (_jumpsPerformed < _maxJumps), we'll check if _wallJumping is true. If it is, we'll set the movement direction to the wall's normal and reset the number of jumps performed. Otherwise, we'll perform a regular jump.

Players can now jump off walls, adding an extra layer of movement and complexity to your game.

In this update, we created a wall jumping system that detects wall collisions and adjusts the player’s movement accordingly. When the player jumps and is close to a wall, they can perform a wall jump, allowing them to reach new heights and explore previously inaccessible areas.

Wall jumping is a powerful and engaging mechanic that will keep players engaged and challenged throughout their platforming adventure. Keep iterating and polishing your game, adding more unique mechanics and level designs to create a captivating platformer experience.

--

--