![]() |
Eye of the Nile Docs
Everything you need to know to get started!
|
Moves entities when they jump on a spring tile. Change the spring's mass (and other properties) to change how bouncy the spring appears. To adjust the height of the spring tile, place it 1 tile above the floor, then set the "Distance" on the Spring Joint 2D to be where you would like the spring to end up.
Documentation updated 12/29/2024
Make the amount that the spring launches the entities based on the mass of the entity and how compressed the spring is.
Give the spring itself some positive velocity when launching.
Prevent the spring from getting stuck in the floor.
Public Member Functions | |
void | LaunchSpring () |
Launch the entities on the spring upwards by adding launchSpeed to their y velocities. | |
Public Attributes | |
float | launchSpeed = 50f |
The speed at which the spring tile will launch entities at. | |
Protected Attributes | |
MovableEntityDetector | entityDetector |
Detects the entities that are standing on the platform (controlled by a different script). | |
GameObject | supportTexture |
Object of the texture under the spring tile that makes it visually connect to the ground. | |
GameObject | anchor |
The point under the spring tile that the Spring Joint 2D connects to. | |
Private Member Functions | |
void | Awake () |
Set reference to the moving platform's rigidbody and initial target point. | |
void | Update () |
If the spring was not compressed, but an entity is on the spring and the spring is moving downwards, then it is compressed. If the spring is compressed, wait for it to stop compressing, then launch the spring. | |
Private Attributes | |
Rigidbody2D | rb |
Reference to the spring tile's rigidbody component. | |
bool | compressed |
Used for making sure the spring only launches when it's compressed. | |
|
private |
Set reference to the moving platform's rigidbody and initial target point.
void SpringTile.LaunchSpring | ( | ) |
Launch the entities on the spring upwards by adding launchSpeed to their y velocities.
|
private |
If the spring was not compressed, but an entity is on the spring and the spring is moving downwards, then it is compressed. If the spring is compressed, wait for it to stop compressing, then launch the spring.
Additionally, scale the height of the support texture to match the height of the spring. The height is precisely the difference between the anchor point and the bottom of the platform.
|
protected |
The point under the spring tile that the Spring Joint 2D connects to.
|
private |
Used for making sure the spring only launches when it's compressed.
|
protected |
Detects the entities that are standing on the platform (controlled by a different script).
float SpringTile.launchSpeed = 50f |
The speed at which the spring tile will launch entities at.
|
private |
Reference to the spring tile's rigidbody component.
|
protected |
Object of the texture under the spring tile that makes it visually connect to the ground.