Jumping
Learning paths through this topic
The second jump in the air should feel like a jump, even while falling
Press jump again in the air and sometimes you barely slow down, sometimes you shoot far past the first jump. The bug is in how the new push is combined with the speed the character already has. Here is the rule that makes every second jump the same.
Double-tap the jump key to start or stop flying in a creative mode
Sandbox games let builders fly, and the usual switch is two quick taps on jump. Done naively the flight turns on and off by itself, a held key counts as many taps, or three fast taps flip it twice. Here is the small bit of timing that makes the gesture dependable.
A downward sword strike that bounces you up off whatever it hits
Striking downward onto an enemy or a row of spikes and popping back up is a favourite move. It breaks when one swing bounces many times, when it bounces off the ground, or when the extra jump never comes back. Here are the rules for one clean bounce per swing.
Loot that pops out of a chest should hop a few times and then rest
Dropped items look dead when they just appear, and look broken when they bounce forever, roll into walls or fly out of reach. Here is a small arc for loot with a few hops that die away on their own, a landing spot you can predict, and a limit that keeps it within arm's length.
An enemy that leaps at you and lands where you will be
Enemies that jump are either harmless, because they land where you were, or they cheat with a straight line through the air. A real leap has an arc with a peak you choose. Here is how to compute it so the enemy comes down on a target that keeps moving.
Launching yourself with your own explosion, strength by distance
Shoot the floor at your feet and fly. Sounds fun, but the blast either does nothing when you stand on the ground, throws you the wrong way, or breaks when the blast is exactly under you. Here is how to aim the push and when it must be bent upward.
Damage from a long fall, measured the way players expect
Falling damage based on speed is unfair: a small hop onto a spring hurts, a long fall slowed by a cap does not. Measuring from the highest point seems right, yet walking off a ledge, double jumps and water bring odd results. Here is the measurement that holds up.
Jumping off a cliff into a pool should hurt less, but not always
Players love leaping into water to survive a long drop, and designers hate the opposite extremes: water that cancels every fall, or a puddle that saves you from a skyscraper. Here is how depth, drop height and the shape of the pool decide how much of the fall is forgiven.
A long fall passes straight through a thin floor or roof
Dig a deep shaft, build a tall tower and jump: after a few seconds the character is falling so fast that a thin plank or a ceiling of one layer is simply skipped between two frames. Here is how to land on what was crossed, and why the fall needs a top speed.
Hold down to fall faster, without spoiling the jump arc
Players love to drop quickly onto a target. But a fast-fall key that works too early chops the jump short, and a hard speed limit makes the character jerk the moment the key is released. Here is a fall that speeds up and eases back cleanly.
A flap-to-fly game where spamming the button flings the bird into the sky
With a tap-to-flap mechanic, a fast tapper or a phone that reports taps twice gets a wildly different result from a calm one. Hand-tuned gravity cannot save it. The mistake is what a flap does to the speed. Here is the version that behaves the same for everyone.
Walking on the ceiling: jumps and landings when gravity flips
A zone that turns gravity upside down is a favourite trick, and half the character code quietly breaks. The jump goes into the floor, the cut-short jump does the opposite, and landing is never detected. Here is what has to be written relative to gravity instead of up.