How to add Double Jump to your Game

Sometimes we want to challenge the player in our games, adding more obstacles to make the gameplay harder. Then you get into a point when you add double jumps, forcing the player to jump twice to reach some roof, get into new path or simply avoid some obstacle.

How do we handle with double jumps?

Let’s explain a little bit this code. Here we have a State Machine to determine when the player is jumping or not, inside the TickState method we define how the jump should be implemented. First, the game checks if the Jump key is triggered and if the double jump bool variable is true.