How to check how long the player is falling before hitting ground?

My team needs a good way to check how long the player is falling before hitting the ground. We have a death script that works when they hit the ground but not a good way to check while they are in a falling state. What would be a good way to check if the player was falling before hitting the ground for 5 or 10 secs? If someone could help out that would be great.

Start by having a “grounded” variable. Place an empty game object called “Grounded” below the player model, and in your update, check to see if a ray shot from your player to the grounded game object intersects the ground (any objects with the tag “Ground” for example).

Also, in your update, whenever not grounded, start a timer. Then you can do:

if (character wasn’t grounded but now they are)
Calculate the time since they WERE grounded. Did they fall too far?

You could also try saving position.Y or something, and then checking it when re-grounded, to see if they went too far in the “falling” direction.