How does the corona physics engine calculate collision force in postCollision Listener?

Hi there! I was building a physics based game and this has been bugging me for quite some time now. I had declared two physics bodies(boxes in shape), then applied a force(a constant force) on one box to make it collide with the other. I was using a postCollision Listener to print the force of the collision(event.force). What I noticed was the value of force is different for different point of collisions. for eg. The force when the box collides with the other box’s edge(sides) is less compared to that when it collides with one of its corners(vertices). I reckon this could be because of multiple contact points in the first case, and only one point of collision in the second case. So does this mean box2d takes the average of forces applied at different contact points? 

I want to know, is there a way to get same force on collision irrespective of the point(s) of collision. I am making a game where you smash some crates, I’ve given a threshold force and any force greater than that will smash it. But it seems that for same value of force the crate gets smashed when hit on corners and not when hit on the sides. 

If anyone still didn’t get the problem I’m sure the video enclosed will help you. Would love to hear from you guys.

Thanks

Karun

Short answer: No.

I guess that this is the same reason as why it is better to break a window in the corner than at the middle.

Anyway, the ‘reason’ is because a smaller area with the same energy applied will contain greater force because that energy is not distributed across a larger body.

While you’re writing in the correct place, your original assumption (I assume) is wrong: It is not “the Corona physics engine” but is in fact the Box 2D physics engine. From it’s own site:

Box2D is an open source C++ engine for simulating rigid bodies in 2D.

So the ‘reason’ you might be looking for is because the effect you’re seeing is a true simulation of the real world, in 2D.

Thanks for the reply :slight_smile: Yes I know its box2D, as a matter of fact I had gone through the entire box2D manual. Unfortunately I couldn’t find the exact method box2D uses to calculate the collision force. I had gone through the corona physics API as well but couldn’t find anything much of help… Is there any way we could get the number of contact points in a collision? If in case box2D calculates the average force(total force/no. of points of contact) then one can calculate force by multiplying the collision force (returned by the listener) with the no. of contact points or anything along the same lines…   

https://docs.coronalabs.com/api/event/postCollision/contact.html

Short answer: No.

I guess that this is the same reason as why it is better to break a window in the corner than at the middle.

Anyway, the ‘reason’ is because a smaller area with the same energy applied will contain greater force because that energy is not distributed across a larger body.

While you’re writing in the correct place, your original assumption (I assume) is wrong: It is not “the Corona physics engine” but is in fact the Box 2D physics engine. From it’s own site:

Box2D is an open source C++ engine for simulating rigid bodies in 2D.

So the ‘reason’ you might be looking for is because the effect you’re seeing is a true simulation of the real world, in 2D.

Thanks for the reply :slight_smile: Yes I know its box2D, as a matter of fact I had gone through the entire box2D manual. Unfortunately I couldn’t find the exact method box2D uses to calculate the collision force. I had gone through the corona physics API as well but couldn’t find anything much of help… Is there any way we could get the number of contact points in a collision? If in case box2D calculates the average force(total force/no. of points of contact) then one can calculate force by multiplying the collision force (returned by the listener) with the no. of contact points or anything along the same lines…   

https://docs.coronalabs.com/api/event/postCollision/contact.html