SPG:Air State

From Sonic Retro

Sonic Physics Guide


  • The research applies to all four of the Sega Mega Drive games and Sonic CD.
  • The following describes physics that only apply when the Player has no special power-up and is not Underwater.


Constant Value
air_acceleration_speed 0.09375 (24 subpixels)
gravity_force 0.21875 (56 subpixels)
top_speed 6


Any time the Player is in the air, they don't have to worry about angles, Ground Speed, slope factor, or any of that jazz. All they have to do is move using X Speed and Y Speed until they detect the ground, at which point they re-enter the ground state.

While the Player is on the ground, X Speed and Y Speed are constantly being updated using Ground Speed, so when the player Jumps or otherwise leaves the floor, X Speed and Y Speed are already set, ready for air motion.

Air Acceleration

When the Player is airborne, they can accelerate twice as fast as on land (air_acceleration_speed).

There is no friction in the air (but there is a complicated drag effect that will be explained later), and pretty much, once the Player has a certain X Speed in the air, they'll just keep going at that speed until you tell them otherwise or they hit a wall.

Furthermore, there is no distinction for deceleration in the air, either, so pressing Left simply subtracts air_acceleration_speed from X Speed no matter what, and pressing Right adds air_acceleration_speed to X Speed.

The Player's top_speed is the same in the air as on the ground, limiting the X Speed.


Gravity (gravity_force) is added to Y Speed in every step in which the Player isn't on the ground. It's what makes them fall downward when they run off of cliffs. It's also what stops them from moving upward forever when they jump.

Top Y Speed

In Sonic 1, the Player's Y Speed is not limited. As they fall, gravity_force continues to be added to Y Speed, increasing indefinitely.

In Sonic CD, however, a limit was introduced so that Y Speed does not exceed 16. This limit is important so that the Player never outruns the camera, or passes through solid ground because they're moving so fast per step that they never even collide with it. Most likely introduced in Sonic CD because of the increased height in the design of levels such as Collision Chaos, and the endless vertical shaft in Tidal Tempest. Without the limit, the Player would accelerate to ridiculous velocities in some of these areas and probably break the game.

Y Speed += gravity_force;
if (Y Speed > 16) Y Speed = 16;

Air Drag

Each step the Player is in the air, a special formula is performed on their X Speed, but only if certain conditions are met: Y Speed must be negative and Y Speed must be more than -4 (e.g. -3, or -3.5, is "more" than -4).

if (Y Speed < 0 && Y Speed > -4)
    X Speed -= ((X Speed div 0.125) / 256);

Air drag is calculated each step before gravity_force is added to Y Speed.

Air Rotation

When the Player leaves a slope, such as running up and off a quarter pipe, the Players's Ground Angle smoothly returns to 0, changing by 2.8125° (2) ($2) each frame, in the direction towards 0. This smooth rotation is used to rotate the Player's sprite back to normal.

  • Note: Regardless of the Player's Ground Angle, their airborne sensors do not rotate. Air collision essentially ignores the Player's angle and treats it as floor mode at all times.