From Sonic Retro

Revision as of 15:26, 18 November 2022 by LapperDev (talk | contribs) (X Speed -> Ground Speed)
Sonic Physics Guide



 roll_friction_speed: 0.0234375
 roll_deceleration_speed: 0.125


When Sonic rolls into a ball by pressing Down on the directional pad, he can no longer accelerate. No matter how hard or how long you press in the direction of his motion, he'll behave as if you weren't doing a thing. The only thing that happens in this case is friction, which is roll_friction_speed, half Sonic's regular friction (in Sonic 3K, Super Sonic's roll friction is hard-coded to always be half of the regular friction).


However, Sonic can decelerate while rolling. If you hold in the opposite direction of his motion, Ground Speed will be slowed by roll_deceleration_speed each frame. Additionally, unlike normal walking, friction is still in effect while decelerating. So in effect, while decelerating, Ground Speed slows by roll_deceleration_speed + roll_friction_speed (or 0.1484375) every step.

Similar to the anomaly explained in Running, if absolute Ground Speed is less than 0.1484375, when this value is subtracted, instead of just setting Ground Speed to zero, Ground Speed is set to 0.5 in the opposite direction. Thus, bizarrely, Sonic can turn around while rolling, even though he can't accelerate!

Top Speed

Now, just because Sonic cannot roll faster on his own, doesn't mean that a nice hill wouldn't give him some momentum every now and then. Gaining speed on slopes is covered in Moving At Angles. These hills and slopes can be used to roll at a very high speed. Just as with running though, Sonic has a top speed cap when rolling as well, though this one is much higher than the former, reaching a top speed of 16 pixels per step. Unlike running however, Sonic cannot surpass this speed cap by any means. If his X Speed reaches a point where it reaches 16, and tries to go higher, it will automatically be set to 16 instead. Notice how I said X Speed instead of Ground Speed, that's right, it caps Sonic's global horizontal velocity, rather than his ground velocity. This can cause the angle he's moving at to be incorrect compared to the angle he's supposed to be moving (though, floor collision will correct this for the Y axis, so Sonic is never misaligned).

The result of all this is that Sonic will be able to outrun the camera while in wall modes, but otherwise won't.

For a more fair limit, you can just cap the Ground Speed instead (before X Speed and Y Speed are set. You can also cap X Speed and Y Speed after to ensure it is enforced). That is, if you want the cap at all.


In Sonic 1, 2, and 3, Sonic can't begin to roll unless his absolute Ground Speed is greater than or equal to 0.5.

In Sonic and Knuckles (and Sonic 3 and Knuckles), this value is increased to 1. This is because Sonic is allowed to duck while his absolute Ground Speed is below 1, so he can perform moves such as the Spindash without needing to come to a full stop (very helpful since Sonic could get stuck weirdly sliding on slopes starting with Sonic 3).

Also in Sonic and Knuckles, probably as a way to combat the anomaly associated with turning around while rolling in the previous games, Sonic unrolls if absolute Ground Speed falls below 0.5.

Typically it will not be, but if Sonic's Ground Speed happens to be 0 (can happen in an S Tunnel) when he curls up to roll, his Ground Speed will be set to 2.

Rolling Jump

In Sonic 1, 2, 3, and Knuckles, you can't control Sonic's trajectory through the air with the LeftRight buttons if you jump while rolling. This makes it kind of hard to Spindash to gain speed, and then make a precise jump. Though, in Sonic 3 and in Sonic & Knuckles, you can regain control of the directional keys if you perform a Insta-Shield, or any other jump ability.

However, in Sonic CD and Mania, you can control a jump made while rolling, as if it were a totally normal jump. This is probably more fair to the player.