An easier thing to do would be to use a maximum fall velocity threshold. Every frame you would check to see if the velocity would be over this and then if it is, set a flag that tells the script to 'kill' the object on collision with the ground.
If you did want to do it with distance, every frame, check the Y (vertical) velocity and if it is less than (moving down) a really small negative value (to account for inaccuracies with floating point values) (say < -0.01f), set the current Y value in a starting height variable. When the collision Y value (where they hit the ground) is greater than the allowed fall distance (10 meters in this case), kill the hero.
I would recommend using acceleration (change of velocity between frames) as that gives the most realistic simulation of impact damage (from a fall, for instance) (it is the stopping that kills you, not the fall).
There are issues involved with using a time or distance approach because in theory, if you fall 100 meters in 24 hours (falling over that entire interval but moving really slowly), both of those methods would most likely kill you but it would be incredibly unrealistic. If you ever have upward forces applied to your hero (for example, from knockback from gunfire, or drag from the 'air'), then you should not use time or distance methods.
P.S. Sketch models are known to not be very efficient when it comes to using them as a mesh for a model. They are not optimized when exported.
↧