Platformer Enhancements - Wall Jumping

Index

Stats

10,602 visits, 42,867 views

Tools

Limiting the number of Wall Jumps

22. Lets go back to our event sheet. All we need to put a system in place to limit the number of wall jumps a player can do is add one variable, and then adjust it depending on what the player is doing. In our case I will create a variable call wallJumpCount. I will start this variable at 0, and each time the player wall jumps, I will add one to it. In my jump events I will check to see if the number is less than 2 and if so they can still wall jump. If it is above two they cannot wall jump which lets us choose how many wall jumps in a row they can do. I will also add an event that each time the player lands on the floor, the variable is reset to 0 so the player can start wall jumping again at their next jump. Add a new global variable on your event sheet called wallJumpCount. Set it to 0. To do this right click the event sheet and choose add global variable.

23. Update our wall jump events to test if wallJumpCount is less than 2. Also update them to add 1 to wallJumpCount as the last step of the wall jump. This will make it so that if it is less than 2 they can wall jump, and for each jump will add 1 to it. So once it hits 2, they will no longer be able to wall jump until they land on the ground again. Your event sheet should now look like the following:

24. Test your project. Note that once you wall jump twice you can no longer wall jump. Also notice that even after you land you can no longer wall jump. To fix this we need to add a new event that checks to see if the player is has landed.

25. Add a new event to our sheet that checks to see if the player is on the floor. This means they have landed and will be able to wall jump again the next time they jump. Add a new condition on your sheet.

Player Platform is On floor System Set wallJumpCount to 0

Your event sheet should now look like the following:

26. Test your project and you should now be able to wall jump a few times and then will have to land if you want to be able to do it again. Notice that even though we said check if wallJumpCount is equal or less than two, but it still lets us do it three times currently? That is because the variable starts at 0. Each wall jump adds 1 to it so it goes 0, 1, 2 then turns off. You can adjust the number in your events to allow for more or less jumps.

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!