- Home /
Adding fall damage with the default FPSWalker
I need to add fall damage to my game and I can't use the FPSWalkerEnhanced script because I have already built everything else around the default FPS Controller. Is there any way in doing so?
Start by looking at the isGrounded variable. Watch if this remains false for a long period of time, then consider calculating an amount of damage to apply to the character once this becomes true again. You will need to do some checks that the player is in fact falling rather jumping, so start calculating damage to apply after you know how long it takes to finish a reasonable jump, or keep track of the movement direction of the character and calculate damage if you know its falling, etc etc.
adding onto what alucardj said, you should also add a default amount you can take so if you fall only a short distance you dont take damage.
Answer by luckruns0ut · Aug 31, 2013 at 04:26 PM
I would simply check whether the player's velocity has dramatically changed since the last frame (or whenever), and if it has, apply damage according to the velocity change. You could also use this to have realistic velocity impacts if that interests you... Such as a car crash impacting health.
If something is falling, at say vec(0,-50,0) velocity at one frame, and then in the next it is at vec(0,0,0), that means they have fallen and then hit something because they have came to a sudden halt. You could use that difference to scale your health damage, or check if the distance is above a certain value to make it so that you don't get damaged by any changes above 10, for example.
There are of course simpler ways to do it, but I'd do it this way so that I could easily scale damage accordingly, rather than specifying exact fall lengths for each amount of damage you can take.
Your answer
Follow this Question
Related Questions
how do i make a script that calculate how much damage did i loss 1 Answer
For loop on collision (two hit kill) 2 Answers
Falling Damage 1 Answer
FireBall script 1 Answer
Enemy health drops but not if first enemy lives, how do i change that? 1 Answer