[solved]Calculating force w/ Physics for damage

Get help using Construct 2

Post » Fri Feb 08, 2013 3:49 am

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?theubie2013-02-08 05:32:48
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

Post » Fri Feb 08, 2013 4:20 am

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.
ImageImageImage
B
67
S
19
G
124
Posts: 3,219
Reputation: 74,425

Post » Fri Feb 08, 2013 4:32 am

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.theubie2013-02-08 04:49:54
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

Post » Fri Feb 08, 2013 5:21 am

Demo

Simulation perfect? Nope, but it feels real enough for what I'm trying to achieve.
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

Post » Fri Mar 08, 2013 4:57 am

[QUOTE=theubie] Demo

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

Can you post the CAPX?
B
30
S
10
G
7
Posts: 416
Reputation: 7,239

Post » Fri Mar 08, 2013 8:13 am

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
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

Post » Fri Mar 08, 2013 8:47 am

@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...BluePhaze2013-03-08 08:49:11
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Fri Mar 08, 2013 7:24 pm

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.
B
26
S
8
G
3
Posts: 210
Reputation: 5,973


Return to How do I....?

Who is online

Users browsing this forum: Colludium and 28 guests