[solved]Calculating force w/ Physics for damage

  • I'd like to base damage in an upcoming game with physics enabled objects for collisions between objects.

    I THINK I just need to multiply the velocity X by velocity Y by the Mass of the object to get a reasonable "force" for which to base my damage on...but my brain doesn't want to accept this as accurate.

    Thoughts?

  • I've just started trying: abs(Physics.VelocityX) + abs(Physics.VelocityY)

    The velocity can go negative or <1, so you don't want to negate the strong force (I'm guessing). If you think multiplying suits you better, I'd add min(1,...) for each, to keep each multiplier above 1.

    Just some thoughts.

  • Right. Would have to take the absolute value. Also guess it would have to be relative to the other object's velocity as well, since there will be two moving bodies.

    delta(abs(x) + abs(y)) would get the relative velocity, then plug that into for both objects with their masses to figure out the force imparted on the other.

    That makes sense, for what little Physics I remember from 2 decades ago in the classroom.

    Edit: Also, before I make some poor physics major's head explode, I realize now after more research that I'm wanting momentum (P=mv) and not Force (F=ma).

    Right method, wrong formula.

  • Demo

    Simulation perfect? Nope, but it feels real enough for what I'm trying to achieve.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Demo

    Simulation perfect? Nope, but it feels real enough for what I'm trying to achieve.

    Can you post the CAPX?

  • I can do you one better:

    I finally got around to writing a full tutorial to it. You can skip the tutorial and grab the capx from the bottom if you wish.

    Using Physics object's momentum to assign damage

  • theubie your tutorial may have some typos in the formula... shouldn't it be:

    Abs(Object1.Physics.VelocityX ? Object2.Physics.VelocityX) + Abs(Object1.Physics.VelocityY ? Object2.Physics.VelocityY)

    instead of:

    Abs(Object1.Physics.VelocityX ? Object1.Physics.VelocityX) + Abs(Object2.PhysicsVelocityY ? Object2.Physics.VelocityY)

    Object1 and 2 were mixed up, and there were some . (dots) missing...

  • Wouldn't surprise me. If you look at the revision count at the top you'll notice I've had a lot of things I've tried to correct.

    Thanks for catching that. Sometimes my mind's working faster than the fingers are typing.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)