# Mass* Acceleration = Damage?

Get help using Construct 2

### » Mon Mar 04, 2013 5:52 am

Hi. I need to do a type of F=M*A equation to calculate damage for my character (or perhaps something a little simpler) and I'm having a bit of trouble with it. This is what I have working:

((Building.Physics.Mass * (abs(Building.Physics.VelocityX) +abs(Building.Physics.VelocityY))) * 0.008)

This works pretty well, except that if you are standing on something that happens to be moving fast (like driving a car or riding a skateboard), it will kill you...

Can anyone help me out with a better equation?
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

### » Mon Mar 04, 2013 6:22 am

Have it check the difference between the speeds of the two objects. Therefor if you check player speed and skateboard speed, you can tell them game "The difference is 1mph" and the game goes "skateboard can't kill/dmg due to insufficient relative force"
B
23
S
10
G
6
Posts: 351
Reputation: 5,151

### » Mon Mar 04, 2013 6:37 am

so would it be something like this?
abs((total player velocity) - (total object velocity)*mass) = damageSushin2013-03-04 06:40:57
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

### » Mon Mar 04, 2013 7:36 am

I am going to have to do a tutorial over this. Seen it pop up a couple of times recently. I had this exact question a while ago:

Here is a demo of rocks smashing into each other in space using the momentum forumla to figure out relative damage based on velocity and mass: Demo

And here's the capx (r120.2). Basically, you want to add each object's x velocity and y velocities together, then add those two results together to get a relative velocity. Since that velocity can be negative, you take the abs of that relative velocity and use it with the mass of the object to get your momentum. After that, you decide how much damage each unit of momentum is worth and wreak havoc.
B
27
S
8
G
3
Posts: 210
Reputation: 6,048

### » Mon Mar 04, 2013 7:59 am

Thank you, but it doesn't seem like this formula compares the direction of the forces, in which case, if two asteroids are moving very fast together in a similar direction they touch slightly, they take the same amount of damage as if they rammed head on.Sushin2013-03-04 08:05:42
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

### » Mon Mar 04, 2013 9:56 am

My wording was a little off in my post, the capx has it correct.

You actually subtract the two X and two Y velocities.

So, given:
Object 1: Vx=10, Vy=0
Object 2: Vx=11, Vy=1

You would get:
abs((10-11) + (0-1))
abs(-1+-1)
abs(-2)
Relative Velocity of 2

Sorry about the confusion in the post itself. It's really late/early here.
B
27
S
8
G
3
Posts: 210
Reputation: 6,048