Day 94: Wall Jumping in Unity

Objective: Allow for the player to Wall Jump

Today we will allow the player to jump off walls to finish the puzzle. To start off we will need to add a new Vector3 variable called _wallJumpDirection. Next we will need a bool to know if the player can wall jump.

We will learn about a new Unity method that is used with the CharacterController. The method is called OnControllerColliderHit();

Inside the method we will check to see if the player is not grounded by using _charController.isGrounded. We will also check to see if we collided with the wall by using CompareTag.

To see the direction of the hit.point from the wall, we can use Debug.DrawRay(). It takes in the starting position of the ray, the direction of the ray and finally the color.

In the editor, you can see a blue line that represents the ray as seen below.

Now we know the direction of the ray we will assign the _wallJumpDirecton to equal the hit.normal. Then we can set _canWallJump to true.

In our original jump check we will also check for _canWallJump == false.

After the original jump section we will check for Input from the space key and if _canWallJump is true. In that section we will set _yVelocity to equal the _jumpHeight. We will also multiply the_wallJumpDirection by _playerSpeed and assign it to _velocity.

Now our player can jump off of walls!!

Thank you for reading and have a wonderful day!




I am passonate on learning to program and use Unity to become a skillful Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium


INDUSTRIA Becomes a Member of the Accord Project

Loading the HHAR CSV data set into a SQL database Part 2: activity data

Error while building PHP docker image in mac

Create Jasper Reports and deploy as a JAR

Heroku Explained


Deploy an Angular with S3 and CloudFront

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
Tyler Smallwood

Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer

More from Medium

Pushing Objects in Unity to Complete Puzzles

Shaking Your Virtual Cameras in Unity 2020

OnClick Event in Unity

Light her up — Adding emissions to your game objects using photoshop and blender