Now you have not only created a wall jump behavior, you have seen the different ways you can tweak it. Feel free to experiment with it to get it to work the way you want in your game.
We also implemented a system for limiting wall jumps if you need one, as well as a way of using the wall jump in a power up scenario if you don't want it to always be an available action for the player. These are of course optional and the goal was to show you different ways you can implement the behavior in your games. I am always open to feedback so please let me know if this tutorial helped you and if you have any other gameplay mechanics you would like me to make a tutorial on let me know. My next tutorials will most likely focus on adding double jumping, dashing (ground and air) and Run/Turbo behaviors to your games.
Further Enhancement/Extra Credit
If you are looking for other enhancements you could add to the wall jump here are some ideas:
- Limit it to only working when they actively jump (Currently it will work even if they are falling off a ledge since we are only testing for "Not on Floor"). This could be done using another variable that gets set when they hit the jump button.
- Make the player has some visual indicator that the power up is active. For example have them change color, or have a visible timer for the power up.
- Allow wall jumping only when walls of a certain type (rock, dirt, some type of rough material) are used. That way you can have slick walls that they cannot wall jump off of.
- If your game is going to support multiple power ups, you will want to come up with variables for each one so the names need to be a bit more specific than powerUp. Also, you may want to implement them as instance variables instead of global variables if you are going to have different playable characters with different abilities, or support multiple players.
- Turn the basic power up system created in this game and turn it into a permanent skill unlock system to allow your characters to learn new skills as the game progresses.