
I’m a huge platformer fanatic. This starts with Donkey Kong, matures with Pitfall and solidifies with Super Mario Bros. -the best jumping in video games that even Nintendo themselves can’t replicate.
Let’s make a glossary for the sake of this discussion…
Jump
Launching something away from the ground at some direction and some velocity which will be affected by a force (usually gravity) in order to return it to the ground. (Note: typically a plain-ole jump but this stuff could apply to slingshot-ting birds, firing cannonballs, etc.)
Return
Your return to the ground after jumping/launching
Jump Velocity
The strength or speed of your jump
Jump Direction
The angle or direction of the jump
Forces
Gravity, wind, friction or some other directional force that affects a jump in some way but the user has no control over.
Dynamic Velocity
Player has control over the strength or speed of your jump to some extent
Dynamic Direction
Player has control over the direction or angle of your jump to some extent
Committed Jump
A jump over which the player has no control of velocity or direction once launched (see: Castlevania, Scorched Earth, Angry Birds)
Dynamic Jump
Player has control of velocity, direction or both to some extent once launched. (see: Super Mario Freakin’ Bros., Sonic, Crash Bandicoot)
Floaty Jump
Dynamic jump into weak gravitational force resulting in oversteering through a slow return. Floaty jumps make it hard to apply your built in real-world understanding of physics resulting in unintuitive control. i.e. it sucks.
How do game developers program a jump?
First off, if your game does not rely on complex collisions with weird shapes or is not some sort of simulation you do not have to use a physics engine. You can write the code yourself.
I’m not discouraging the use of physics engines or other people’s code but if you’re really going to tweak the gameplay to perfection make sure you know how to change every value in the code like gravity, friction, velocity, etc.
How do developers code a jump?
Probably something like this:
If the player presses the jump button turn on gravity for the player and thrust him upward at a velocity that is higher than the force of gravity.
Since the gravity is always on (as long as you’re jumping) it will eventually override the vertical velocity and pull you back down. This results in a nice realistic smooth curve.
When the player hits the ground-turn off gravity for the player.
What can we tweak to make it more fun? Vertical stuff.
- Vertical forces like updraft or gravity. For best result make it relate-able to real life so players can accurately gauge a jump-but don’t overdo it.
- Vertical velocity value, the length of time that velocity applies (leave it on for a jetpack)
- Player control over the length of time velocity applies. Here’s where Super Mario Bros. nailed it. The player can tap the button for a small jump or hold it for a higher jump. They can control the height of the jump by holding the button down longer. Genius!
After a set height however the player must come down so they do eventually lose control of the vertical velocity. Remember: the level design really matters here. Super Mario Bros. has three platform heights that Mario can jump to on any given screen. This means there are times that you can do a little vertical climbing even though the game is horizontally oriented (but this isn’t a discussion in level design so…)
That covers vertical motion. What about horizontal?
Good ole physics dictates that we can calculate vertical and horizontal math separately. So here’s what happens with horizontal:
The player can either NOT have control over movement in the air or they can press forward and backwards to guide the jumper. Friction should be added for a good heavy feel.
What can we tweak to make it more fun? Horizontal stuff.
- Horizontal forces like friction or horizontal wind. For best results have friction so there is a weight to the player.
- An object in motion tends to stay in motion. You shouldn’t be able to turn on a dime in the air.
- Horizonal speed at the time of jump affects the angle or direction of the jump. In Super Mario Bros. you have to be running to make a long jump. Although you can “steer” in the air, it is limited and the weight of the character feels great.
I simply want developers to think about and spend time on perfecting these values and forces. If you’re lucky it’ll feel like Super Mario Bros.
Now go play Super Mario Bros. and think about the forces, feel the control and you’ll start to understand why the jumping in Super Mario Bros. itself is fun to play with and has kept players coming back for over 25 years.