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.

Making the player jump

Making the player jump - Unity Tutorial

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

Start my 1-month free trial

Making the player jump

- Now that we know when the player is standing, we can make him jump. This is going to be one of our more complicated behaviors because it's gonna rely on a bunch of different behaviors and states to actually make this work. First, we're gonna need to go into our Scripts folder, into Behaviors and create our jump script. Then let's open this inside a MonoDevelop. Once open, we're gonna want it to extend our abstract behavior. Next, we'll wanna create a method that'll allow us to jump. In this case, we're gonna think ahead a little bit and make this a protected virtual method. This way, we can extend and override this class to make variations on the jump script later on. Here we'll call this OnJump. Now before we can fill this out, we're also gonna wanna make sure that we actually have a speed for when to make the player jump. In this case up at the top, we'll make a public float and we'll call this one JumpSpeed and we'll set it to 200. Now back in our OnJump method, we can begin the…

Contents