Monday, September 18, 2017

Wall running woes, part 1

There's a design flaw in the code for level collisions when you're running on a wall. In addition to raw X and Y velocity, the player object tracks an extra value, ground velocity, which is your speed along whichever surface you're running on. Later, this value gets multiplied by the sine and cosine of the player's current angle in order to calculate the actual displacement along the X and Y axes.

Normally, this value is cleared when you run into a wall. However, when you bump into a solid level block while running up or down a wall, your ground velocity isn't cleared, because you're not actually running into a wall, you're running into the floor or the ceiling!


When you run into the floor, the solid blocks underneath prevent your character from actually moving. However, due to gravity, your ground velocity continues increasing and eventually, the displacement experienced in a single frame is so large, your character's bounding box travels beyond the range of the solid blocks, sending you right through the floor.


The developers knew of this limitation in the collision engine, which is why the issue doesn't occur in the more obvious places. For instance, in Carnival Night Zone, you can easily get yourself running on the walls by simply jumping at the rounded corners in the ceiling. If you run down the wall, though, your character will land properly on the floor.


The trick is to introduce an invisible "GTGT" collision marker object right where the wall meets the floor. Object collision is completely indifferent to the player's running direction, forcing them to stand up when the object is stood upon.

1 comment:

  1. So this is what happened when flamewing started porting over Sonic 3 & Knuckles physics into Sonic Classic Heroes. I remember posting a video about this, and it's a glitch that clearly did not happen in earlier builds of SCH.

    ReplyDelete