Nerd For Tech
Published in

Nerd For Tech

Wall Jumping in Unity

Next up, let’s see how we can figure out how to wall jump. First thing we will need to adjust is how the player reacts when jumping. As it stands now, the player can freely more direction in mid air, which physics wise makes no sense:

If order to adjust this, we will want to move our horizontal moving actions to the isGrounded method so that it will prevent us from moving while we are floating in the air:

With our movement adjusted slightly, we can see how it looks within the game:

Now that we are preventing our player from moving, let’s look at some logic behind how the player interacts with it’s surroundings a little:

With this quick debug, we can see how our player contacts the surfaces:

We can see with the blue lines that show up, the points of contact we have with the ground and the walls. From here, we have to figure out a method in which we have our play jump perpendicular t the wall on the other side:

What we are doing here is telling Unity that the new variable we have created, _wallJump is equal to the hit.normal of the contact from the wall. As for the return method, we have this in place so that unity checks to see if the conditions have changed so that it can activate walljump. With this, we can move into our jumping method and make a couple additions to give the method to wall jump:

What we are doing here is using our new _wallJump variable to be able to push ourselves off of the wall. From there, we need to give our player a little bit of height when they jump from the wall so that they can continue in an upwards trajectory:

Now that we have wall jumping in place, let’s see how we can interact with a moveable object so we can press a button to continue onwards.

--

--

--

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 https://www.nerdfortech.org/.

Recommended from Medium

If you want something, just do it.

Network Load Balancing with Nginx Proxy Port Pass Deployment on EKS

How to Build a Basic Scraper using Python Scrapy?

GIF to illustrate how exactly Scrapy works

iOS Interview Questions and Answers for Senior Developers Part 4 — Concurrency

Frank Tobias on the impact of experimentation and engineering culture at Preply

nerdctl: Docker-compatible CLI for contaiNERD

How to monitor OracleDB ACTIVE/INACTIVE Sessions on WebLogic?

Choose the most suitable inductor for your DC-DC converter (2)

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
Jordan Evans

Jordan Evans

More from Medium

Building A Stealth Game — Helping Your Guards “See”

GamePad Support w/ New Unity Input System

Adding proximity detection so enemies can ram player

Using Post Processing Volumes in Unity3D with the URP