Actions

SPG:Underwater

From Sonic Retro

Sonic Physics Guide
Collision
Physics
Gameplay
Presentation
Special

Notes:

  • The research applies to all four of the Sega Mega Drive games and Sonic CD.
  • For information about the Air Bubble Maker object and the physics of water bubbles, see Game Objects

Air

While underwater, the Player can last 30 seconds before drowning. The Player's air value (we'll call this remaining_air) starts at a value of 30 upon entering the water. As you would imagine, once remaining_air reaches 0, the Player will drown.

This value represents the amount of seconds of air the Player has left. Meanwhile, a timer counts down from 60 each second. Each time this timer reaches 0, the "air event" occurs:

Air Event

Each air event, the following happens:

Air Check

Firstly, remaining_air is checked. At certain air values, different actions will be performed:

  • [25, 20, 15] a warning chime is sounded.
  • [12] the drowning music begins.
  • [12, 10, 8, 6, 4, 2] a warning number bubble (the count down) will be emitted (these will be the numbers 5, 4, 3, 2, 1, or 0).
  • [0] Sonic drowns.

Air Decrease

Secondly, 1 is subtracted from remaining_air.

Small Breathing Bubbles

Thirdly, small breathing bubbles are emitted from the Player's mouth.

Small breathing bubbles spawn at the Player's X Position + 6 (or X Position - 6 when facing left) and at the Player's Y Position.

The number of small breathing bubbles is either 1 or 2, chosen at random (the is an equal chance of either amount). If the number of small breathing bubbles is 2, the second will spawn at a random interval between 1 to 16 frames later.

Notes:

  • The sine movement of the bubble is adjusted based on the way the Player is facing to ensure the bubble begins by moving away from the Player's mouth.
  • When moving through a water tunnel like those in Labyrinth Zone, the small breathing bubbles that spawn will move to the right by 4 pixels per frame.

Count Down Warning

If at the current air event a countdown bubble is to be emitted, this countdown bubble will be spawned as if it were one of the small breathing bubbles from the Player's mouth.

If only 1 small breathing bubble is emitted, that must be the number bubble. If 2 small breathing bubbles are to be emitted, there is a quarter chance that the first will be the countdown bubble, otherwise the second small breathing bubble must be the countdown bubble.

Large Air Bubbles

When a large air bubble is breathed, the Player's remaining_air is reset to 30 and the timer is reset to 60. Any drowning music is cancelled. Note:

  • For the collision and mechanics of bubbles, see Game Objects.

Physics

When the Player is underwater their speeds are modified to that they move much more slowly, but otherwise the physics are largely the same. This is achieved mostly by halving the pertinent variables, but some, like gravity and initial jump velocity, are not exactly half.

Water Entry and Exit

When the Player enters the water, their X Speed is multiplied by 0.5, and their Y Speed is multiplied by 0.25 quartering it (this occurs after gravity_force is added to Y Speed).

When the Player exits the water, their Y Speed is doubled (after water gravity_force has been added), (however, X Speed is not affected when leaving the water). If the Player is being controlled by another object (like being carried by Tails), Y Speed will not be affected.

Also, if the Player's Y Speed is less than -16 it will be limited to -16 upon exiting.

Constants

 acceleration_speed: 0.0234375 (half of 0.046875)
 deceleration_speed: 0.25 (half of 0.5)
 friction_speed:  0.0234375 (half of 0.046875)
 top_speed: 3 (half of 6)
 
 air_acceleration_speed:  0.046875 (half of 0.09375)
 
 roll_friction_speed: 0.01171875 (half of 0.0234375)
 roll_deceleration_speed: 0.125 (unchanged)
 
 gravity_force: 0.0625 (instead of 0.21875)
 jump_force: 3.5  (3 for knuckles) (instead of 6.5  (6 for knuckles))
 jump_release: -2 (instead of -4)

Getting Hit

When getting hit underwater, the Player will fly back with an X Speed of 1 (or -1) and a Y Speed of -2, half that of normal.

Bubbles

When the Player gets a bubble underwater, their X Speed and Y Speed are both set to 0.

Speed Shoes

When in possession of Speed Shoes, but also underwater, the underwater variables take over, effectively nullifying the Speed Shoes altogether. No calculations, such as multiplying by 0.5, take place.

Drowning

When the Player drowns, their X Speed and Y Speed are both set to 0, and the gravity_force remains set to the lower water gravity.

Drowning Bubbles

When drowning, 11 bubbles are created from the Player's mouth as they fall offscreen. The first bubble can spawn from 0 to 15 frames after drowning, chosen at random. Subsequent bubbles spawn 1 to 8 frames apart, also chosen at random.

Each of the 11 bubbles has a quarter chance of being a medium bubble, otherwise it will be a small bubble.

Animation Speeds

Being submerged doesn't affect the speed of the Player's animations at all. Variable Speed Animations will be attenuated by the same proportion automatically.