Events based on the speed of a collision

0 favourites
  • 7 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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. <img src="smileys/smiley36.gif" border="0" align="middle" />

  • '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.

  • 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?

  • 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).

  • Thanks for the tips... PS you did mean "VelocityX, and VelocityY" vs. VectorX, and VectorY... correct?

  • Indeed.

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