Basic Double Jump With Unity’s Character Controller

Double-jump is extremely common in many games, so it’s something that should be fairly straightforward to implement. With Unity this is definitely the case, as all the logic is fairly basic and nothing changes from the way jump would normally be implemented.

A very basic double jump

As you can see here, all we need to read input is the jump button that can be mapped to any key (which is better than hard mapping your input keys in code). From there our character controller knows if we’re on the ground, so if we are, we set some the flag for double jump and set our jump speed (which I’m replacing fallSpeed here with so that I can do something fancy later). If we’re not on the ground, but we have double jump, we just set our jump speed again, and make sure to set the flag to disable double jump so that we can’t jump again until we’re back on the ground.

The actual jump doesn’t happen until after we set our moveDirection, which takes into account fallSpeed that in this case has been repurposed to jump. We then use this to calculate the new vector for our character.

Moving characters using the character controller from here is easy. We just need to feed in our vector, and of course take time into account.

As you can see, this was pretty easy to pull off. It’s no wonder so many small developers chose Unity for making simple games such as those for mobile or game jams. If you’re looking to get started in game development, I highly recommend you give Unity a look, as even if you don’t stick with it forever, it is a very straightforward way to get started and learn some of the core concepts of making games.

Game developer with over 12 years of experience, mainly focused on MMOs.