Fall damage

Hello there community.
I am trying to make a 2D puzzle platformer but I am having some problems with my “fall damage” script.
The code works, sometimes… I have no idea why it doesn’t work all the time.

When a player falls from a high platform and get a vertical velocity of over 80 I assign the variable lethalSpeed to true, the problem is that you can shift gravity while in mid-air so even if you at one point during the airtime have lethalSpeed you might survive if you gravity shift and land on a platform before you reach lethalSpeed.

I have been trying to debug the code with Debug.Log, but it seems it doesn’t enter for example respawnI() even if the conditions in the if-statement are met(should be met).

I would apreciate any feedback figuring this out or if I can improve anything.
And as I said, it works sometimes.

private void checkPlayerState()
   {
        if (!grounded)
        {
            currentSpeed = Mathf.Abs(rigidbody2D.velocity.y);
            if (currentSpeed > 80f)
                lethalSpeed = true;
            else
                lethalSpeed = false;
        }
        if (grounded && lethalSpeed)
        {
            respawn ();
        }
    }

private void respawn()
    {
        gameObject.transform.position = currentCheckPoint;
        currentSpeed = 0;
        lethalSpeed = false;
    }

EDIT: Problem solved!

It could be that you are hitting the ground causing your speed to drop below 80f before your death check kicks in. This will reset your lethalSpeed to false. So you are on the ground but not dead.
Maybe switch the Death check “if (grounded && lethalSpeed)” section to before the “if (!grounded)” section to avoid this.