Actions

Difference between revisions of "SPG:Getting Hit"

From Sonic Retro

(Consistency)
(New formatting)
 
(3 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
*''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]].''
  
==Collision with Hazards==
+
==Intro==
 +
Getting hit is when the player makes contact with something harmful. Either a harmful [[SPG:Solid_Objects|solid object]] like Spikes, or a harmful [[SPG:Hitboxes|hitbox]], like a  [[SPG:Game_Enemies#Badniks|Badnik]].
  
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.
+
==Constants==
 +
{| class="prettytable" style="width: auto;"
 +
!Constant
 +
!Value
 +
|-
 +
|'''hurt_x_force'''
 +
|''2''
 +
|-
 +
|'''hurt_y_force'''
 +
|''-4''
 +
|-
 +
|'''hurt_gravity_force'''
 +
|''0.1875 (48 subpixels)''
 +
|}
  
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.
+
==Getting Hurt==
  
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.''
+
When the Player has rings and collides into a Badnik (while uncurled) or other hazard, such as spikes or a field of lava, they are flung backwards and [[SPG:Ring_Loss|lose their rings]]. During this special hurt state, their physics behave quite differently.
  
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.
+
The Player becomes [[SPG:Ring_Loss#Invulnerability|invulnerable]] for a short time.  
  
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''').  
+
'''''Y Speed''''' is set to '''hurt_y_force''' at the moment of impact, and '''''X Speed''''' is set to '''hurt_x_force''' 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.
  
Air drag is not applied while hurt.
+
Note: ''The above is true even for being hurt by large lava fields and long rows of spikes (both of which are triggered by object hitboxes). The direction the Player is flung is always based on which side of the hazard's '''''X Position''''' they're on.''
  
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.
+
Even if the harmful object is above the Player, their '''''Y Speed''''' is set to ''-4''. If the object is above and is solid, like spikes, they'll detect the ceiling 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.
  
==Collision with Walls==
+
===Hurt State===
 +
While in the hurt state, the Player does not react to controller input. Also, Gravity is changed from the [[SPG:Air_State#Constants|normal value]] to '''hurt_gravity_force''' until they land. When they do land, their '''''X Speed''''' is set to ''0'', so that they stop completely.
  
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.
+
[[SPG:Air_State#Air_Drag|Air drag]] is not applied while hurt.
  
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.
+
====Exiting Hurt State====
 +
The Player cannot leave the hurt state until they land on the ground or on a [[SPG:Solid_Objects|Solid Object]].
 +
 
 +
Note: ''In your framework, you may wish to change this by 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.''
 +
 
 +
When the Player leaves the hurt state, Gravity is returned to normal.
  
 
==Dying==
 
==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.
+
When the Player has no rings and touches a harmful object, they will enter their death state. '''''X Speed''''' is set to '''0''', and '''''Y Speed''''' to '''-7'''. Gravity is set to the [[SPG:Air_State#Constants|normal value]].  
 +
 
 +
The Player takes no input at this point. While in their dying state, they detect no collisions with [[SPG:Solid_Tiles|Solid Tiles]], [[SPG:Solid_Objects|Solid Objects]], object [[SPG:Hitboxes|hitboxes]], or [[SPG:Underwater|water]] surfaces.
 +
 
 +
==Other Types==
 +
===Collision with Walls===
 +
 
 +
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.
  
 
[[Category:Sonic Physics Guide|Getting Hit]]
 
[[Category:Sonic Physics Guide|Getting Hit]]

Latest revision as of 04:29, 18 June 2023

Sonic Physics Guide
Collision
Physics
Gameplay
Presentation
Special

Notes:

Intro

Getting hit is when the player makes contact with something harmful. Either a harmful solid object like Spikes, or a harmful hitbox, like a Badnik.

Constants

Constant Value
hurt_x_force 2
hurt_y_force -4
hurt_gravity_force 0.1875 (48 subpixels)

Getting Hurt

When the Player has rings and collides into a Badnik (while uncurled) or other hazard, such as spikes or a field of lava, they are flung backwards and lose their rings. During this special hurt state, their physics behave quite differently.

The Player becomes invulnerable for a short time.

Y Speed is set to hurt_y_force at the moment of impact, and X Speed is set to hurt_x_force 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 being hurt by large lava fields and long rows of spikes (both of which are triggered by object hitboxes). The direction the Player is flung is always based on which side of the hazard's X Position they're on.

Even if the harmful object is above the Player, their Y Speed is set to -4. If the object is above and is solid, like spikes, they'll detect the ceiling 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.

Hurt State

While in the hurt state, the Player does not react to controller input. Also, Gravity is changed from the normal value to hurt_gravity_force until they land. When they do land, their X Speed is set to 0, so that they stop completely.

Air drag is not applied while hurt.

Exiting Hurt State

The Player cannot leave the hurt state until they land on the ground or on a Solid Object.

Note: In your framework, you may wish to change this by 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.

When the Player leaves the hurt state, Gravity is returned to normal.

Dying

When the Player has no rings and touches a harmful object, they will enter their death state. X Speed is set to 0, and Y Speed to -7. Gravity is set to the normal value.

The Player takes no input at this point. While in their dying state, they detect no collisions with Solid Tiles, Solid Objects, object hitboxes, or water surfaces.

Other Types

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.