Events based on the speed of a collision

Get help using Construct 2

Post » Fri Jan 20, 2012 4:41 am

I'd like to be able to know what the force of a collision is to determine if it was just a "bump" or enough to trigger a "kill" etc.

If you think of Angry Birds... a light tap does nothing to a pig... a medium hit gives a black eye... and enough hits or a big hit destroys the pig.

In a similar way in my physics based game I'd like to know how hard an impact is.

If there is a way to do this I'd love to know (legit or a hack ;-)

Cheers,
Steve
B
7
S
2
G
4
Posts: 9
Reputation: 2,963

Post » Fri Jan 20, 2012 4:53 am

You can use the AngularVelocity expression of the physics object to tell how fast it's going. Test what the value is upon collision, and from there you decide how high it has to be to be a light, medium, or hard hit.

Lemme know if you need an example whipped up -- or if this doesn't work. It might not, since I don't actually use the physics behavior myself.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Fri Jan 20, 2012 9:49 am

'AngularVelocity' is the speed the object is rotating at - to get the overall speed use distance(0, 0, Sprite.Physics.VectorX, Sprite.Physics.VectorY). Other behaviors have a 'speed' expression. You just need to check this in the collision event.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Mon Jan 23, 2012 2:41 am

thanks for the ideas... i'm guessing that the distance(0, 0, Sprite.Physics.VectorX, Sprite.Physics.VectorY) is what I need... the only trick I have now... (and sorry for being so naive) is where can I use this expression?
B
7
S
2
G
4
Posts: 9
Reputation: 2,963

Post » Mon Jan 23, 2012 4:57 pm

You can use expressions about wherevere you have a text field.

So you can use expressions in the system condition "compare", in actions, etc...

I guess what you could use would be system: compare two values, put distance(0, 0, Sprite.Physics.VectorX, Sprite.Physics.VectorY) in the first field, and a comparison value in the second field (> 0 for example, would mean that the action would happen anytime your object is moving, since its velocity is not 0).
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Wed Jan 25, 2012 1:34 am

Thanks for the tips... PS you did mean "VelocityX, and VelocityY" vs. VectorX, and VectorY... correct?
B
7
S
2
G
4
Posts: 9
Reputation: 2,963

Post » Wed Jan 25, 2012 2:28 am

Indeed.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests