![]() |
Eye of the Nile Docs
Everything you need to know to get started!
|
Script for the squasher hazard. When the player enters the squasher's trigger zone, it falls under gravity. When the squasher hits the ground, it stays there for a moment before returning. This script goes on the trigger zone of the squasher hazard.
Documentation updated 12/24/2024
Public Attributes | |
float | fallSpeed = 1f |
The gravity scale at which the squasher will fall. | |
float | returnSpeed = 3f |
The speed at which the squasher returns to its starting position. | |
bool | allowFallCancel = false |
Set to true to let the squasher stop falling the moment player exits its trigger zone. If false, it can't stop falling until it hits the ground. | |
bool | allowReturnCancel = false |
Set to true to allow the squasher start falling while it's returning to its starting position. If false, it can't start falling until it's at its starting position. | |
float | groundTime = 1.5f |
When the squasher hits the ground, this is how long it stays stuck to the ground (measured in seconds). | |
Private Member Functions | |
void | Update () |
Handle the logic for the four states that the squasher can be in: | |
void | OnTriggerEnter2D (Collider2D col) |
When the player enters the squasher's trigger zone and the squasher is ready to fall, make it fall. The squasher is considered ready to fall when: | |
void | OnTriggerExit2D (Collider2D col) |
If the squasher is allowed to cancel its falling state, then when the player leaves the trigger zone, let it go back to its starting position (sets state to "RETURNING"). | |
Private Attributes | |
GameObject | squasher |
The squasher hazard that falls when it detects a player. | |
GameObject | fallingDamageHitbox |
Hitbox on the bottom of the squasher that will only be active when the squasher is falling. | |
GameObject | crushingHitbox |
Hitbox within the squasher that can only hurt the player if the player clips into the squasher. Always active, but usually only affects the player when the player gets pushed into the ceiling by the squasher. | |
GameObject | returnPoint |
The point that the squasher will return to after falling. | |
float | groundTimeCounter = 0f |
Keeps track of how long the squasher has been on the ground (measured in seconds). | |
string | state = "IDLE" |
The four states the squasher can be in are "IDLE", "FALLING", "GROUNDED", and "RETURNING". It will typically cycle through these four states. | |
|
private |
When the player enters the squasher's trigger zone and the squasher is ready to fall, make it fall. The squasher is considered ready to fall when:
col | Represents the object that entered the trigger zone. |
|
private |
If the squasher is allowed to cancel its falling state, then when the player leaves the trigger zone, let it go back to its starting position (sets state to "RETURNING").
col | Represents the object that entered the trigger zone. |
|
private |
Handle the logic for the four states that the squasher can be in:
bool SquasherHazard.allowFallCancel = false |
Set to true to let the squasher stop falling the moment player exits its trigger zone. If false, it can't stop falling until it hits the ground.
bool SquasherHazard.allowReturnCancel = false |
Set to true to allow the squasher start falling while it's returning to its starting position. If false, it can't start falling until it's at its starting position.
|
private |
Hitbox within the squasher that can only hurt the player if the player clips into the squasher. Always active, but usually only affects the player when the player gets pushed into the ceiling by the squasher.
|
private |
Hitbox on the bottom of the squasher that will only be active when the squasher is falling.
float SquasherHazard.fallSpeed = 1f |
The gravity scale at which the squasher will fall.
float SquasherHazard.groundTime = 1.5f |
When the squasher hits the ground, this is how long it stays stuck to the ground (measured in seconds).
|
private |
Keeps track of how long the squasher has been on the ground (measured in seconds).
|
private |
The point that the squasher will return to after falling.
float SquasherHazard.returnSpeed = 3f |
The speed at which the squasher returns to its starting position.
|
private |
The squasher hazard that falls when it detects a player.
|
private |
The four states the squasher can be in are "IDLE", "FALLING", "GROUNDED", and "RETURNING". It will typically cycle through these four states.