Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Programming Physics: Representing Damage With a Formula?  (Read 926 times)

noodle0117

  • Bay Watcher
  • I wonder what would happen if I pull it.
    • View Profile
Programming Physics: Representing Damage With a Formula?
« on: October 24, 2013, 02:07:42 am »

I have been thinking about this little question for quite some time now, but haven't really come to a conclusion. It feels a little awkward trying to explain this on a physics forum, but hopefully my ideas will be a bit more understandable on a game forum.

If I were to implement a hit-point system for a game where you lose health based on how hard you get smashed around by different objects, which formula makes a more accurate depiction of the amount of "damage" you receive?

Assume all objects are rigid bodies (no deflation, deformation, bending ect.)

Damage = Change in (1/2 * mass * velocity^2)
(formula for change in kinetic energy, 1/2 constant optional)

- or -

Damage = Change in (mass * velocity)
(formula for change in momentum)

Also, I know there will undoubtedly be many more constants to consider, but for ease of reading, I'll just keep the formulas bare and simple.
Logged

da_nang

  • Bay Watcher
  • Argonian Overlord
    • View Profile
Re: Programming Physics: Representing Damage With a Formula?
« Reply #1 on: October 24, 2013, 03:51:01 am »

Well, it's all about the force, not the velocity, that causes damage, isn't it? A change in velocity can occur at different rates, so I'd probably go with change in momentum but tie it in with force through impulse.
For example:

DamagedI/dt = d(mv)/dt or Δ(mv)/Δt for the average force.

Additionally, you can also take into consideration the jerk and yank.

There's also pressure, of course. Ice can shatter if a large enough force is distributed on a small surface.
Logged
"Deliver yesterday, code today, think tomorrow."
Ceterum censeo Unionem Europaeam esse delendam.
Future supplanter of humanity.

Sergarr

  • Bay Watcher
  • (9) airheaded baka (9)
    • View Profile
Re: Programming Physics: Representing Damage With a Formula?
« Reply #2 on: October 24, 2013, 03:53:22 am »

Use the second one, the first one wouldn't work because otherwise you'll get stuff like a boucning object (velocity => - velocity) recieving no damage.

EDIT:Ninja'd
Logged
._.

noodle0117

  • Bay Watcher
  • I wonder what would happen if I pull it.
    • View Profile
Re: Programming Physics: Representing Damage With a Formula?
« Reply #3 on: October 24, 2013, 02:00:24 pm »

One of the main things that keep me from just thinking the change in momentum is the "correct" formula for damage is because of this trope: http://tvtropes.org/pmwiki/pmwiki.php/Main/KineticWeaponsAreJustBetter.
Logged

da_nang

  • Bay Watcher
  • Argonian Overlord
    • View Profile
Re: Programming Physics: Representing Damage With a Formula?
« Reply #4 on: October 24, 2013, 02:22:35 pm »

One of the main things that keep me from just thinking the change in momentum is the "correct" formula for damage is because of this trope: http://tvtropes.org/pmwiki/pmwiki.php/Main/KineticWeaponsAreJustBetter.
It all depends on the rate of change. You can have all the time in the world to slow down a fast object but the change in kinetic energy would still be the same and you probably wouldn't get even a scratch.
Logged
"Deliver yesterday, code today, think tomorrow."
Ceterum censeo Unionem Europaeam esse delendam.
Future supplanter of humanity.

acetech09

  • Bay Watcher
  • Bay Watcher
    • View Profile
Re: Programming Physics: Representing Damage With a Formula?
« Reply #5 on: October 24, 2013, 02:27:16 pm »

A bit of context about the type of damage would be great. Because, depending on the target, a grain of salt at 500m/s might be much more lethal than a thrown table.

You did ask for help in a DF forum, you know. Where damage can never be that simple.
Logged
I challenge you to a game of 'Hide the Sausage', to the death.

Another

  • Bay Watcher
    • View Profile
Re: Programming Physics: Representing Damage With a Formula?
« Reply #6 on: October 24, 2013, 02:29:19 pm »

Why would you not combine the two?

I was thinking about this subject previously and some kinds of damage can be inflicted by bone crushing heavy relatively slowly moving objects and other - by kinetic energy released from point of impact of a bullet. Why not use a_1*m*dV+a_2*m*d(V^2) for some coefficients a_1, a_2? (Which IMHO should also depend on the surface area of impact and other local geometrical and material characteristics.)
Logged

noodle0117

  • Bay Watcher
  • I wonder what would happen if I pull it.
    • View Profile
Re: Programming Physics: Representing Damage With a Formula?
« Reply #7 on: October 24, 2013, 04:15:44 pm »

Why would you not combine the two?

I was thinking about this subject previously and some kinds of damage can be inflicted by bone crushing heavy relatively slowly moving objects and other - by kinetic energy released from point of impact of a bullet. Why not use a_1*m*dV+a_2*m*d(V^2) for some coefficients a_1, a_2? (Which IMHO should also depend on the surface area of impact and other local geometrical and material characteristics.)

That... is actually quite a nice idea, although I'd probably require a lot of fiddling with constants to get it just right.

It all depends on the rate of change. You can have all the time in the world to slow down a fast object but the change in kinetic energy would still be the same and you probably wouldn't get even a scratch.
Ah, forgot to include it in the thread post, but this is assuming all calculations occur in a given (presumably short) timeframe.

As to the context of the type of damage, I'm thinking of making a 2D physics based combat game similar to Hammerfight, except with a much more significant use of guns and kinetic ranged weaponry. Ammunition comes in all forms from tiny bullets to heavy ballista bolts to massive cast-iron cannonballs. Ideally, I would model all projectiles under a single formula, but doing so seems rather tricky if I want all projectiles to deal "realistic" amounts of damage.
Logged