Eye of the Nile Docs
Everything you need to know to get started!
Loading...
Searching...
No Matches
SpringTile Class Reference

Detailed Description

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

Author
Alexander Art
Todo

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.
 

Member Function Documentation

◆ Awake()

void SpringTile.Awake ( )
private

Set reference to the moving platform's rigidbody and initial target point.

◆ LaunchSpring()

void SpringTile.LaunchSpring ( )

Launch the entities on the spring upwards by adding launchSpeed to their y velocities.

◆ Update()

void SpringTile.Update ( )
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.

Member Data Documentation

◆ anchor

GameObject SpringTile.anchor
protected

The point under the spring tile that the Spring Joint 2D connects to.

◆ compressed

bool SpringTile.compressed
private

Used for making sure the spring only launches when it's compressed.

◆ entityDetector

MovableEntityDetector SpringTile.entityDetector
protected

Detects the entities that are standing on the platform (controlled by a different script).

◆ launchSpeed

float SpringTile.launchSpeed = 50f

The speed at which the spring tile will launch entities at.

◆ rb

Rigidbody2D SpringTile.rb
private

Reference to the spring tile's rigidbody component.

◆ supportTexture

GameObject SpringTile.supportTexture
protected

Object of the texture under the spring tile that makes it visually connect to the ground.


The documentation for this class was generated from the following file: