Platformer Enhancements - Wall Jumping

7

Index

Stats

22,518 visits, 74,022 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 28 Jan, 2013. Last updated 19 Feb, 2019

Creating the Basic Wall Jump Behavior

8. Before we start working with the events themselves, we need to add another object to our project. Since the platform behavior means our player will jump when we hit the up arrow, we need to be able to add our own events that also happen when the player hits the up arrow. In order to detect what key the player has hit, we need to add the keyboard object to our project. Double click on the layout background and insert the keyboard object.

9. Now for the real magic, for the most basic wall jump capabilities we are going to add 3 conditions to check for. We need to check if the player has hit the up arrow, if the player is currently jumping, and if there is a wall next to the player. Basically, we are going to say, if I hit the up arrow, am already jumping and there is a wall next to me, do something. We will create sub-events to check if we are next to a wall since we have to check if the wall is to the right or left and react accordingly. To create a sub event, you select your condition, and hit the S button, this will allow you to create a sub event. The sub event only gets evaluated if the conditions above it are true. So basically, if the player is hitting the up arrow, and is jumping, then the conditions checking if they are near a wall will run, at that point it will check which side the wall is on and then react accordingly. We are adding to sub events because we need to the behavior to be different based on which side of the player the wall is. Without sub events, we would have to do this as two separate events that are almost identical. Adding sub events gives us more logic options and saves us a little bit of duplication of code.

10. First lets create our primary conditions. These will be evaluated every time as they are common between all wall jump events. Add the following events to your event sheet:

Keyboard On Up Arrow Pressed

Player Platform is Jumping

11. Select the Keyboard On Up Arrow Pressed condition that we just created and hit the S key on your keyboard. This will allow you to create sub event/condition. In our case we want to create the following sub event (we will do this twice, once for the left and once for the right).

Player Platform has wall to right

Player Platform has wall to left

Your event sheet should now look like this:

  • 0 Comments

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