1
$\begingroup$

To begin, let me clarify this:

Fall damage is environmental damage inflicted upon a player when he falls from a certain height.

In other words, when my players falls from a certain height, I need the player to take damage. I've thought about many different ways to approach this, but none of my approaches worked correctly. If it helps, I have a property that displays velocity, it uses the following: getLinearVelocity().length. Also, I have an object which is above all the floors in my scene. It has the property "floor" to identify it.

How would I approach creating fall damage?

$\endgroup$
1
$\begingroup$

I don't know if you're accepting logic bricks answer, but you can simply have a property on the floor that the player can detect (or in some cases just sense for any collision at all). When the Collision sensor reads false, you can just make the player enter the "fall" state. You should be doing this anyway, so it won't be too hard to add a timer to sense how long the player has been airborne. You want to set it high enough so that the normal jump, or a jump slightly downhill doesn't activate it.

Next, remember, it's not falling that hurts people, but the ground. So when the player hits the ground, before wiping the timer, check the value. If it was over your fall limit, damage the player by a multiple of the remainder. (ie.falls 4 sec. limit was 2.5, multiplier was 3: damage the player by 7 health.) This is reliable, and the more you fall, the more you get damaged. Realistically, you would use an exponential function, but no-one likes falling 10 meters in a game and dying.

In the .blend, practice dropping the man from different heights.

$\endgroup$
  • 1
    $\begingroup$ Thank you for the answer. Unfortunately, I have a few problems. I've tried this attempt previously, and didn't use it for the following: there are times in my scene where the player's fall speed changes (meaning that the player would get more/less fall damage; unfair/unreasonable), parts of a scene that push the player who is already midair (again, the player could be boosted on a higher platform, and barely even fall, yet take loads of fall damage). Thanks though. $\endgroup$ – blackhole Feb 2 '16 at 21:51
  • 1
    $\begingroup$ Add properties that extend the fall limit to the things that boost the player. And then set it back when it touches the floor again. Change the multiplier based on the velocity. This might not be the most efficient idea, but it is quite simple. $\endgroup$ – Pythogen Mar 31 '16 at 2:50
  • $\begingroup$ we could also try using something along the lines of storing a world position, and then comparing them, so this only gets hurt after there is motion down. like "if oldPosition > newPosition..." $\endgroup$ – Scalia Apr 2 '16 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.