How can I detect if the player fell from the top of the map to the bottom?

I want the player to unlock an achievement if he fell from the top of the map to the bottom. I’ve tried doing and if statement if it took the player x amount of seconds to hit the ground, but I soon realized that the time it takes can be unreliable. Plus I have air lifts, so someone could sit on the air lift for a bit, floating then touch the ground and unlock it. How would I go about doing this? The map looks like this.

may be check rigidbody2D.velocity.y

or something like:
last.transform.position.y - transfom.position.y, last is position where object was for x seconds.

private bool wasAtTopOfLevel = false;
void Update() {
if (PlayerIsAtBottomOfLevel() && wasAtTopOfLevel) AchievementUnlocked();
if (PlayerCharacterIsGrounded() ) wasAtTopOfLevel = false;
if (PlayersYPositionIsTopRow() ) wasAtTopOfLevel = true;
}

The 3 functions are left as an exercise for the reader, but that’s the basic logic you can use.

1 Like

Also everyone is going to recognize such a direct clone of that elephant game.

1 Like