Actions

Difference between revisions of "SPG:Getting Hit"

From Sonic Retro

(Cleanup and consistency, added SPG table of contents)
(Consistency)
Line 2: Line 2:
 
'''Notes:'''
 
'''Notes:'''
 
*''The research applies to all four of the [[Sega Mega Drive]] games and [[Sonic CD]].''
 
*''The research applies to all four of the [[Sega Mega Drive]] games and [[Sonic CD]].''
 
The following only applies when [[Sonic]] is on flat, dry land with no special power-ups.  Curves, water physics, [[Super Sonic]], and [[Speed Shoes]] will be covered in separate guides.
 
  
 
==Collision with Hazards==
 
==Collision with Hazards==
  
When Sonic has rings and bumps into an enemy or other hazard, such as spikes or a field of lava, he's flung backwards. During this special hurt state, his physics behave quite differently.
+
When the Player has rings and bumps into an enemy or other hazard, such as spikes or a field of lava, they are flung backwards. During this special hurt state, their physics behave quite differently.
  
His Y speed is set to '''-4''' at the moment of impact, and his X speed is set to '''2''' times ''a'', where ''a'' is the sign of Sonic's X position minus the hazard in question's X position. If ''a'' would be '''0''', it defaults to '''1''' so that Sonic can never be flung straight upward. The direction Sonic's sprite is facing, however, does not change.
+
Their Y speed is set to '''-4''' at the moment of impact, and their X speed is set to '''2''' times ''a'', where ''a'' is the sign of the Player's X Position minus the hazard in question's X Position. If ''a'' would be '''0''', it defaults to '''1''' so that the Player can never be flung straight upward. The direction their sprite is facing, however, does not change.
  
Note: The above is true even for lava fields and rows of spikes. The direction Sonic is flung is always based on which side of the centre of the hazard he's on.
+
Note: ''The above is true even for lava fields and rows of spikes. The direction the Player is flung is always based on which side of the centre of the hazard they're on.''
  
Even if the harmful object is above Sonic, his Y speed is set to '''-4'''. If the object is solid, like spikes, he'll detect the collision in the next step and Y speed will be set to '''0'''. This results in Sonic appearing to just fall away from the hazard.
+
Even if the harmful object is above the Player, their Y Speed is set to '''-4'''. If the object is solid, like spikes, they'll detect the collision in the next step and Y speed will be set to '''0'''. This results in the Player appearing to just fall away from the hazard.
  
While in the hurt state, he takes no player input. Also, gravity is changed from '''0.21875''' (the normal value) to '''0.1875''' until he lands (perhaps they thought this reduced gravity gave the player more time to react). When he does land, his X speed is set to '''0''', so that he stops dead. Also, he enters into an invulnerability state which lasts for '''120''' frames ('''0x78''').  
+
While in the hurt state, the Player does not react to controller input. Also, gravity is changed from '''0.21875''' (the normal value) to '''0.1875''' until they land. When they do land, their X Speed is set to '''0''', so that they stop dead. Also, they enter into an invulnerability state which lasts for '''120''' frames ('''0x78''').  
  
 
Air drag is not applied while hurt.
 
Air drag is not applied while hurt.
  
He cannot leave the hurt state until he hits the ground. In your engine, you may wish to change this, adding a timer that returns him to a normal falling state when it runs out. This is more fair, because without this fix Sonic can be knocked off of a high ledge, and the player is unable to regain control for quite some distance.
+
The Player cannot leave the hurt state until they hit the ground. In your framework, you may wish to change this, adding a timer that returns them to a normal falling state when it runs out. This is more fair, because without this fix the Player can be knocked off of a high ledge and they will be unable to regain control for quite some distance.
  
 
==Collision with Walls==
 
==Collision with Walls==
  
In the [[Sonic the Hedgehog 2 (Nick Arcade prototype)|Sonic 2 Nick Arcade prototype]], if Sonic hits a wall at his top X speed of '''6''', he will bounce away with the identical physics as if he was hit by a harmful object - altered gravity and all. The only differences are that he doesn't lose his rings, and when he lands he spends a few steps in his knocked flat animation.
+
In the [[Sonic the Hedgehog 2 (Nick Arcade prototype)|Sonic 2 Nick Arcade prototype]], if the Player hits a wall at their top X speed of '''6''', they will bounce away with the identical physics as if they were hit by a harmful object - altered gravity and all. The only differences are that the Player doesn't lose rings, and when they land they spend a few steps in the knocked flat animation.
  
 
Granted, this isn't a feature in the finished Sonic 2, or even the later builds of the game, but the effect has been included in the some of the 3D Sonic games.
 
Granted, this isn't a feature in the finished Sonic 2, or even the later builds of the game, but the effect has been included in the some of the 3D Sonic games.
 
To tell the truth, reaching a speed of '''6''' in Sonic 2 is easy enough to do that Sonic seems to be rebounding off of walls all too often, and it gets a little annoying. If you increased the criterion speed to '''12''', it might be a nice effect to leave in your engine.
 
  
 
==Dying==
 
==Dying==
  
When Sonic is killed by a harmful object, his X speed is set to '''0''', and his Y speed to '''-7'''. Gravity remains normal. Of course, Sonic takes no input at this point, either. While in his dying state, he detects no collisions with objects or water surfaces.
+
When the Player is killed by a harmful object, their X Speed is set to '''0''', and their Y Speed to '''-7'''. Gravity remains normal. Of course, the Player takes no input at this point, either. While in their dying state, they detect no collisions with objects or water surfaces.
  
 
[[Category:Sonic Physics Guide|Getting Hit]]
 
[[Category:Sonic Physics Guide|Getting Hit]]

Revision as of 16:53, 28 July 2021

Sonic Physics Guide
Collision
Physics
Gameplay
Presentation
Special

Notes:

Collision with Hazards

When the Player has rings and bumps into an enemy or other hazard, such as spikes or a field of lava, they are flung backwards. During this special hurt state, their physics behave quite differently.

Their Y speed is set to -4 at the moment of impact, and their X speed is set to 2 times a, where a is the sign of the Player's X Position minus the hazard in question's X Position. If a would be 0, it defaults to 1 so that the Player can never be flung straight upward. The direction their sprite is facing, however, does not change.

Note: The above is true even for lava fields and rows of spikes. The direction the Player is flung is always based on which side of the centre of the hazard they're on.

Even if the harmful object is above the Player, their Y Speed is set to -4. If the object is solid, like spikes, they'll detect the collision in the next step and Y speed will be set to 0. This results in the Player appearing to just fall away from the hazard.

While in the hurt state, the Player does not react to controller input. Also, gravity is changed from 0.21875 (the normal value) to 0.1875 until they land. When they do land, their X Speed is set to 0, so that they stop dead. Also, they enter into an invulnerability state which lasts for 120 frames (0x78).

Air drag is not applied while hurt.

The Player cannot leave the hurt state until they hit the ground. In your framework, you may wish to change this, adding a timer that returns them to a normal falling state when it runs out. This is more fair, because without this fix the Player can be knocked off of a high ledge and they will be unable to regain control for quite some distance.

Collision with Walls

In the Sonic 2 Nick Arcade prototype, if the Player hits a wall at their top X speed of 6, they will bounce away with the identical physics as if they were hit by a harmful object - altered gravity and all. The only differences are that the Player doesn't lose rings, and when they land they spend a few steps in the knocked flat animation.

Granted, this isn't a feature in the finished Sonic 2, or even the later builds of the game, but the effect has been included in the some of the 3D Sonic games.

Dying

When the Player is killed by a harmful object, their X Speed is set to 0, and their Y Speed to -7. Gravity remains normal. Of course, the Player takes no input at this point, either. While in their dying state, they detect no collisions with objects or water surfaces.