Tip of the Day: Wall-Jumping in Unity

A very interesting feature that increases player mobility in-game and can add a wow factor to your game is actually wall-jumping. Just having the ability to wall jump can open a lot of new level design options that weren’t accessible before.Here it is …


This content originally appeared on Level Up Coding - Medium and was authored by Mohamed Hijazi

A very interesting feature that increases player mobility in-game and can add a wow factor to your game is actually wall-jumping.
Just having the ability to wall jump can open a lot of new level design options that weren’t accessible before.

Here it is done using Character Controller.

“If you have not setup a character controller before, read our previous article on how to setup one. Read HERE”.

A very useful method in the Character Controller is the OnControllerColliderHit which detects collisions with the player.

So, the logic here is that while the player is jumping, if the player hits a wall, then we detect the collision with the wall and assign the Vector3 normal of that wall we collided into. Now we make use of the Vector3.normal and use it to detect the direction of the wall jump.

This is the Vector3 normal of any plane. Basically it is the vector that is coming out of that plane based on the plane’s angle.

Code

Now that we got the Vector3.normal to detect wall jump direction and allowed the player to wall jump, in the Update() method, we listen for player input and ONLY when the _canWallJump Boolean is true, we add to the Y velocity of the player, and calculate the direction and speed of the jump.

Combing this method with the previous methods (moving with character controller, double jumping, pushing objects) you will have a very flexible and powerful character controller.


Tip of the Day: Wall-Jumping in Unity was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Mohamed Hijazi


Print Share Comment Cite Upload Translate Updates
APA

Mohamed Hijazi | Sciencx (2021-05-10T23:52:44+00:00) Tip of the Day: Wall-Jumping in Unity. Retrieved from https://www.scien.cx/2021/05/10/tip-of-the-day-wall-jumping-in-unity/

MLA
" » Tip of the Day: Wall-Jumping in Unity." Mohamed Hijazi | Sciencx - Monday May 10, 2021, https://www.scien.cx/2021/05/10/tip-of-the-day-wall-jumping-in-unity/
HARVARD
Mohamed Hijazi | Sciencx Monday May 10, 2021 » Tip of the Day: Wall-Jumping in Unity., viewed ,<https://www.scien.cx/2021/05/10/tip-of-the-day-wall-jumping-in-unity/>
VANCOUVER
Mohamed Hijazi | Sciencx - » Tip of the Day: Wall-Jumping in Unity. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/10/tip-of-the-day-wall-jumping-in-unity/
CHICAGO
" » Tip of the Day: Wall-Jumping in Unity." Mohamed Hijazi | Sciencx - Accessed . https://www.scien.cx/2021/05/10/tip-of-the-day-wall-jumping-in-unity/
IEEE
" » Tip of the Day: Wall-Jumping in Unity." Mohamed Hijazi | Sciencx [Online]. Available: https://www.scien.cx/2021/05/10/tip-of-the-day-wall-jumping-in-unity/. [Accessed: ]
rf:citation
» Tip of the Day: Wall-Jumping in Unity | Mohamed Hijazi | Sciencx | https://www.scien.cx/2021/05/10/tip-of-the-day-wall-jumping-in-unity/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.