How to measure the impact strength in a collision

Hi All… 

How would you measure the “impact strength” of a collision?  

I need some sort of “impact measurement” from collisions to decide whether to blow an object or not.  

Thanks,

Santi

You can only do it with postCollision; the parameter is “event.force”.

[lua]

function object:postCollision(event)

  if event.force > 5 then

    print(“Ouch!”)

  end

end

object:addEventListener(“postCollision”)

[/lua]

  • Caleb

Thanks Caleb!  That would do the trick. 

Hi @santiagoluib3,

Caleb is 100% correct. An alternative method, if you don’t want to implement postCollisions, might be to just get the x and y velocity of the moving object when it collides, get its directional velocity using some basic math, and if that value is high enough, explode the other object.

Best regards,

Brent

Hi Brent,

I was actually about to do just that - get the directional velocity and base the explosion from there.  

However, there are many variables to factor in.   The player can explode in many ways , for example  1) when he is in motion and smashes into something stationary or another moving object in positive or negative closure rate,  or  2) Other dynamic objects with varying intensity/size collides the player while the latter is staionary, etc…  So you can see I have to compute the vX and vY of both objects and that makes it a little complex.  :)  

Thanks for the feedback!

Santi

You can only do it with postCollision; the parameter is “event.force”.

[lua]

function object:postCollision(event)

  if event.force > 5 then

    print(“Ouch!”)

  end

end

object:addEventListener(“postCollision”)

[/lua]

  • Caleb

Thanks Caleb!  That would do the trick. 

Hi @santiagoluib3,

Caleb is 100% correct. An alternative method, if you don’t want to implement postCollisions, might be to just get the x and y velocity of the moving object when it collides, get its directional velocity using some basic math, and if that value is high enough, explode the other object.

Best regards,

Brent

Hi Brent,

I was actually about to do just that - get the directional velocity and base the explosion from there.  

However, there are many variables to factor in.   The player can explode in many ways , for example  1) when he is in motion and smashes into something stationary or another moving object in positive or negative closure rate,  or  2) Other dynamic objects with varying intensity/size collides the player while the latter is staionary, etc…  So you can see I have to compute the vX and vY of both objects and that makes it a little complex.  :)  

Thanks for the feedback!

Santi