Nerd For Tech
Published in

Nerd For Tech

Jumping in between two walls in Unity

The exercise here demonstrates implementing wall jumping in Unity.

Without going further into anything, an in built class from the Unity Engine Library has to be understood.

Unity provides an out of the box class that addresses collision based matters.

The player object has a character controller component attached which would allow the usage of the class above.

In the class here, there is a property which solves the task here.


“Surface normal is a vector perpendicular to the surface at a specific point.”

As seen in the image above, the player’s intention while jumping in between is to get a bounce back from the colliding wall and use that momentum to head upwards until reached to the target position.

This surface normal is available in the class mentioned above.

Below is the simple implementation in the player script component.

  • Create two private variables. One would be a flag and Second would be storing the normal vector.
  • Write the method to get the vector data from this class.
  • In the Update method, check for this condition. ( Player is not on ground and _canWallJump is true which means the player has just collided with the wall.)
  • If satisfied, add the normal vector to its velocity multiplied by a certain speed variable. Also, add jump boost to the Y direction speed of the player.

Please keep in mind that the code above shall be inserted keeping other checks as per your program.

That should be it :)

Here is the final result.

Thank you very much




NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit

Recommended from Medium

Building data pipeline with Google Cloud DataFlows through custom template in Apache Beam(Python)

How to develop a custom chatbot with RASA?

Running UGI Application Top of Docker Container…


Safely test and apply changes to your database: getting started with Alembic

New Job! Arming Developers @ Shopify


How to fix Snap error during Flutter installation in WSL-2 Ubuntu.

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
Samarth Dhroov

Samarth Dhroov

Work in Progress.

More from Medium

Transposer Virtual Camera Explained in Unity’s Cinemachine

2D Mobile: Loot System

Ledge Grab System: Part 1

Pushing Objects in Unity to Complete Puzzles