You're completely right, it's been too long.. Still the formulas should be correct.

ANd especially with games, how would you implement getting to the correct form before landing? I have made the assumption (perhaps I should have stated it) that this would be a game similar to 2d platformer in it's mechanics and falling. Then, having predictable damage results but still them being somewhat realistic is what I'd aim for. If we start obsessing over realism the game itself can be advursly affected, we couldn't have creaking doors for example.]]>

Second, after reaching a certain speed, landing on water is like landing on concrete since liquids do not compress. That's why form is so important when doing those 80 foot dives, they need to pierce the surface tension of the water.

Here's a wikipedia article on falling object formula.

]]>v += 9.8/(tv*tv) * dt

tv is the target speed, for a parachute this might be 2 meters per second

But generally, the more realism the more work.]]>

I think, eg if tile is 10, player should loos 1000 health: in each hight, 4 health should be lost: for first 3 hights(if hight is <3) or <5, player shouldn't loos any health

why I sed in each hight 10 health should be loos? we have mountain with hight of 100: in real life, if you fall you'll die? so it should be in game to make it realistic]]>

Physics is fun!]]>

when any object falls down to earth, there are two forces (simplified) working on it:

1. Earths gravity, causing an acceleration (speedup) of 9.8 meters per second.

So if we would only have gravity, we'd end up falling faster and faster and faster with the same acceleration, 9.8 meters per second.

2. The air resistance, and here it gets interesting.

The air resistance is squared compared to the velocity. If you don't understand, it basically means that for small velocities the air resistance is allmost not present, but the larger the velocity, the larger the air resistance becomes, eventually balancing out gravity and making someone go down with a constant velocity (terminal velocity). Notice that when someone has a constant velocity the acceleration is 0 (Do you understand why?)

According to my google efforts, the max speed for a human falling down is 53 meters per second. This will yield the following:

v -= 9.8*dt; // gravity, we are falling down so negative

v += 0.003488786045 * v * v * dt; // air resistance for human

And here dt is the time elapsed since last computation. So let's say you check movement every 5 ms it will be 0.005. You can use the elapsed value from a timer.

So now you only have the impact velocity when something hits the ground. How you map it to health is dependent on your game.

else if (this.v.y < -9.8*dt)

{ // This is when you hit the ground after falling.

falldamage = this.v.y * fallfactor;

// landsounds, etc

this.v.y = 0; // assuming you don't want to bounce.

}

I tend to like values between 5 and 7 for v.y when jumping, but the important thing to remember is that whatever v.y is at the start of a jump, it will be negative that when landing. So you should avoid falldamage for any value of v.y greater than minus jumpspeed, at least.

And dt is how much time each frame covers. If you're using timers, this will be time.elapsed * 0.001. If you're using fixed frame lengths, it's whatever that is.

]]>damage = damage factor * velocity ^ 2

where velocity is the speed at which your character is going down. The sign doesn't matter here because of the square

So unless there are different gravities into the game, you don't need to divide by the acceleration, because the damage factor can just absorb it by being 9.8 times larger. Whenever you want to model something in a game, what's important is to know how it scales, then you can fine tune factors. In your case, you can choose different factors for different surfaces like post 8 said.

I don't know if you have basic physics notion, so here is a summary:

When we fall, we accelerate. On earth, the acceleration is -9.8 m/s^2, depends on where you are on Earth, there are some variations, but let's say it's -10 m/s^2. It's negative because by convention when it's going down it's negative and going up is positive. Since Earth's acceleration is towards earth, so dowon that is, it's negative by convention.

The unit m/s^2 can be read "meters per seconds squared", but don't be confused by that unit. You know velocity is "meters per second" or m/s, then acceleration is "meters per second, per second" or (m/s)/s or m/s^2. Basically, if I accelerate at a rate of 10 m/s^2, it means my velocity will increase by 10 m/s every second.

So say I'm in the air and my velocity is -5 m/s. Here minus means it's going down, I'm falling at this very instant at 5 m/s. But my velocity increases as I'm accelerating. After 0.5 seconds, my velocity is now -10 m/s. After another 0.5 seconds, so 1 second from start, it's at -15 m/s and so on.

In a game, we usually update parameters by ticks. So if you have a game tick every 0.03 seconds, then you would update your verlocity like that, assuming you are falling:

velocity = velocity - 10 * 0.03 = velocity * 0.3

You can update position like that:

position = position + velocity * 0.03

where 0.03 is tick length

When you hit the ground, calculate damage like that:

damage = damage factor * velocity^2

Of course you can add a treshold like post 8 said.

When you jump, just set velocity to some positive value. Say if you sset velocity = 10, then your character will start going up, as velocity is positive and will loose speed as acceleration is negative. After 1 seconds, velocity will be 0, meaning your character doesn't go up nor does it go down and then he will start going down.

Hope that was somewhat clear. But wait! There is more! You can calculate damage even more realisticly. This is because post 8 assumed damage like that:

1) As you fall, you rack up energy. The faster you go down, the more energy you rack.

2) On impact, the ground violently decelerates you, converting that energy into damage for you.

While that is true, it's oversimplifying. You see, base jumpers who can jump from really high without dieing roll and they hit the ground. This is to spread the impact on as much time as possible. It's also to convert some velocity into rotation. This is because what matters is not energy, but power. Power is energy rate so to speak, energy per second. You wouldn't die if you fell from 200m if you had a equally distributed impact over 1 month. What makes the impact kill is that it's really quick, less than a second.

But you cannot roll if you fall straight, so it depends on the angle at which you hit the ground. Angle will change over time of fall, because usually horizontal velocity is constant and vertical velocity is accelerated downwards.

There is also material bounciness, when you fall with high velocity, depending on the impact distribution, the ground material and the character shape and mass, the character will bounce. In real life, some people survived really high fall, until the second impact, meaning when you bounce, the second impact also inflicts you damage.

It also depends on which body parts hit the ground, if you fall on the head... good luck.

There is also air resistance. If you wonder if a free falling object will keep accelerating as it falls infinitely, well no, it doesn't. The fastest you fall, the more air tries to prevent you from accelerating, until you reach a point where air decelerates you so much that it completely evens out Earth's gravity, meaning you have a net acceleration of 0 m/s^2. This speed at which this happens is called terminal speed or terminal velocity and it depends on the shape of an object, it's orientation, mass, etc. This is why a sheet of paper falss slower than a glass, the sheet of paper's terminal speed is very low.

Remember when I said someone falling straight couldn't roll, well if they place their feet off-centered compared to their center of gravity relative to the ground, they can have a lever effect and create a tork converting some of the downwards velocity into rotation. So I simplified there.

What I want to get at is unless you are making a physics simulator, usually in games, we don't aim for realistic, but rather realistic "enough". This is also true for AAA titles. We approximate because it would take too much CPU to do the most exact calculations factoring in all physics concepts. But mostly because what's important in a game is fun. If you'd like your character to roll when he falls and is moving horizontally to reduce damage, just create a rolling sound asset and include that rolling damage reduction in your damage formula. If you want your character to bounce, add materials a bouncing index that will restitute some upward velocity on impact with a decay and a treshold. If you want your character to have a parachute to use air resistance to reduce damage, just set a max velocity with that parachute, say -10 m/s or whatever you like. If you want to put a mechanic that breaks physics, it's ok too, like those games where you can double jump, although it's impossible to jump on air for us humans, it's still a good mechanic.

So yeah, you can totally use damage = damage factor * velocity^2. Is it realistic, well not really. Is it realistic enough? Depends on your game, but mostly yes.

Note: the formulas here are based on Newton equations, but they were proven not exact, especially at high speeds by Einstein. So even using those formulas are simplification, because the difference is so small at low speeds that it doesn't matter.

]]>I'm not even in high school yett! I like complex math but god daaaamn!]]>

= mass times gravity times height

mass and gravity are constants in this instance, so the variable we are concerned is height.

from this equation, the energy of the impact is linearly proportional to height, so it is reasonable to assume the fall damage would scale linearly. so we can just multiply by the height fallen by a constant damage factor.

btw, the height fallen can be derived from the velocity at impact, since

mass times velocity^2 = mass times acceleration times height

so, rearranging:

height = (velocity^2) / acceleration

at least that should be right... been a while since I done physics in high school.

so the basic algorithm would be in pseudo code:

int damage(height) {

if height > minimumDamageThreshhold

return height * damage_factor

else

return 0

}

for some extra realism, the minimum damage threshhold and damage factor can depend on the material of the surface the player fell on, so grass or water would be have greater threshhold and smaller dmg factor and for concrete or a bed of nails it would b the other way around.

]]>