don't click here

Quirky Quarter Pipe Behavior in Sonic 3

Discussion in 'Engineering & Reverse Engineering' started by foobles, Aug 25, 2022.

  1. foobles

    foobles

    Member
    8
    6
    3
    Messing around at the very beginning of Sonic 3, I took some time to scrutinize these quarter-pipe ramps in Angel Island act 1, and noticed some odd behavior:



    • Spindashing up the curve, I am flung off at an angle, indicating that the final tile I touched does *not* have a flagged angle. (I did not hold any inputs while I was flung off)
    • Walking onto the curve slowly from the top, Sonic remains standing perfectly upright and his horizontal movement speed is not impeded at all, indicating that he has an angle of zero.
    • Corroborating the idea that Sonic has an angle of zero, jumping off of the slope in this state sends him straight up.
    • The range where he maintains this zero-angle extends past the top tile of the curve, going quite far down (actually even farther than this video demonstrates)
    • However, when sonic lands back down onto the slope, he immediately runs down the pipe, indicating a *non-zero* angle this time.

    I also checked in debug mode, there are no objects on top of the quarter pipe that could be messing with physics. This leaves a strange contradiction: when Sonic runs up the slope at high speed, or lands on the slope from a jump, he is angled as normal (not even snapped to 90 degrees, meaning this most likely isn't a case of a simple flagged tile), but when walking onto the slope from the top down slowly, he seemingly maintains an angle of zero.

    What is the cause of this? I did not see any discussion of this on the list of Sonic 3 bugs, although it did mention a different bug in quarter pipes where running at certain speeds will make him stop suddenly in the curve. Perhaps that is related?

    Edit: This behavior does not occur in the quarter pipes Sonic 1 GHZ; the edges of the slopes consistently act as steeply angled tiles in all cases.
     
    Last edited: Aug 25, 2022
  2. Lapper

    Lapper

    Member
    1,679
    535
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy: WW, Freedom Planet 2
    I'm not certain as I haven't looked in a while but I beleive this is due to some kind of tolerance check added in S2 where Sonic's angle won't be changed if the difference between his current angle and the angle he's trying to switch to is > 45 degrees (while on the ground).
     
  3. MarkeyJester

    MarkeyJester

    A D V A N C E Resident Jester
    2,112
    243
    43
    Japan
    Lapper is correct.

    Ironically it's this curve instance which might be responsible for the change.

    [​IMG]

    The flat top of the CC block is exposed, leading to this:

    [​IMG]

    Sonic will walk on top of the CC block, it'll rotate him 90 degrees anti-clockwise. Next frame Sonic will try to read the block to his right (because of 90 degree rotation), but that block isn't solid, so the engine assume's he is now in the air and sets his air flag. The block now being read will depend on his X and Y speeds. In this particular demonstration, Sonic isn't moving that fast so his horizontal movement is small, but gravity is increasing due to air mode, so the block below is read again which happens to be CC again. So you get this viscous cycle. This also has another effect whereby, at speed, sometimes Sonic will be forced to run down the curve instead of running off the block as a ledge...

    The fix they applied is what Lapper mentioned above, if the angle being touched is different from Sonic's by 45 degrees or more, Sonic's angle will instead be snapped to his nearest 90 degree angle.

    The problem with this fix is described in your video, those curve blocks are more than 45 degrees from flat land, Sonic is walking from flat land on the right onto those curves, and the engine just forces his angle to snap to flat again, at a certain point in the curve will be less than 45 degrees away and Sonic will start falling down. Landing on it from the air is fine as the routine responsible for the angle fix is for floor walking only, not for in-air detecting the floor.
     
    • Informative Informative x 4
    • List
  4. foobles

    foobles

    Member
    8
    6
    3
    Thank you both, that makes sense. This design decision definitely has tradeoffs, I appreciate the explanation :)