Apply fall damage?

Hi

I know there are a few threads already devoted to fall damage, however I’m trying my best to integrate it striaght intoi my character script.

I’m simply using the unity3 first person character controller.

I know how to simply create the health variable, and alter it when he gets punched, or anything like that, but how do I make it so that when he falls x metres, he loses xtime 10 health, or something simalar?

(also, I only want him to get hurt after a certain amount of falling, not if he jumps up and drops a single metre)

Thanks

Some ideas :

  • Unless I am mistaken, a Character Controller can detect whether he is grounded or not.
  • You can make a function / coroutine that runs in the background, in your script. This script observes whether the controller is grounded or not. When it is not, when the character controller is falling (previousPosition.y - currentPosition.y > 0), you add that difference to a variable.

When grounded become true, check the amount of distance in the variable. If it is greater than an amount, well…

This one has fall damage and is much better than the FPS Walker script included with Unity 2.6: http://www.unifycommunity.com/wiki/index.php?title=FPSWalkerEnhanced

There’s supposedly new scripts for character control in Unity 3, but I’m still using my double modified (I’ve added some goodies to mine on top of Eric’s features) FPS Walker. :slight_smile: