From the course: Advanced Unity 2D: Platformer Player Movement

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Sliding down walls

Sliding down walls - Unity Tutorial

From the course: Advanced Unity 2D: Platformer Player Movement

Start my 1-month free trial

Sliding down walls

- So now that we can make the player actually stick to the wall, what we wanna do is come up with a better way of doing this as well as making the player slide down the wall. Once we get this in place, we'll then be able to add other behaviors, like jumping off the wall. Now while manipulating gravity was a good first attempt, in this next behavior what we're actually gonna do is manipulate the velocity in order to slow the player down when he's sliding down the wall. To get started let's go back into our Scripts Behavior folder, and we'll create a new C# Script, and we'll call this one WallSlide. And then let's open this up in MonoDevelop. Now let's extend all the work that we did and stick to walls and override a few of the methods that'll allow us to customize the way that we slide down the wall. Here we're not gonna need the Start method, so let's remove that. And here let's modify our Update method to take advantage of the update logic in our stick-to-walls behavior. Once we…

Contents