Actions

Path swapper

From Sonic Retro

A path swapper, in Sonic the Hedgehog 2, Sonic the Hedgehog 3, and Sonic & Knuckles, is an object which when crossed switches the player from the low collision plane to the high collision plane or vice versa, depending on where he crossed it from. These games have two separate collision planes, and the solidity of certain 16x16 tiles changes depending on which plane the colliding character is in currently, as governed by their parent 128x128 tile.

The behaviour of a path swapper depends on its subtype. The subtype has the format HGFE DCBA:

  • BA is the collision radius of the object (radius in pixels = $20 * 2^BA)
  • C is the orientation - 0 means the swapper is vertical and operates from left to right and right to left, 1 means the swapper is horizontal and operates from up to down and down to up
  • D is the operation when the player crosses from left to right or up to down - 0 means move to low plane, 1 means move to high plane
  • E is the operation when the player crosses from right to left or down to up - 0 means move to low plane, 1 means move to high plane
  • F indicates if the swapper should set the high priority bit of the player's art tile when the player is crossing from left to right or up to down - if this is 0, the priority bit is cleared, and if it is 1, the bit is set
  • G indicates if the swapper should set the high priority bit of the player's art tile when the player is crossing from right to left or down to up - if this is 0, the priority bit is cleared, and if it is 1, the bit is set
  • H is a flag which if set indicates that the swapper should only change the collision plane when the player is on the ground

In Sonic 2, Sonic 3 and Sonic & Knuckles, path swappers are used for loops and cross paths. Sonic 1, however, does not use path swappers, instead using a more inflexible system for loops, which cannot be applied to create cross paths.