Problem when 2 dynamic objects collide.

I have 2 dynamic objects, a box and a bullet. When the bullet collides with the box, I removed the bullet but the problem is that the box is moving because of the force from collision. So, this is my question, how can I set the box to stand still?

PS. I don’t want the box to be static type that why I have to use dynamic. 

If you set the bullets isSensor property to true, there will not be any force applied to the collision.

https://docs.coronalabs.com/api/type/Body/isSensor.html

Hi Alex, I’ve already set bullet.isSensor to true but the problem is still there. Moreover the force of the bullet seems to affect the shooter too.

Here is my code when I defined the bullet.

local bullet = display.newCircle(character.x,character.y,2) bullet:setFillColor(0,0,0) bullet.type = "bullet" bullet.isSensor = true physics.addBody(bullet) sceneGroup:insert(bullet) bullet:addEventListener("collision",function ( event ) if event.other.type == "monster" then display.remove(event.target) end end) bullet.isBullet = true

you must set isSensor *AFTER* calling addBody (or within the call, via the params) not before

Hi Dave, thanks to your reply, I can solve this problem now. Thank you very much.

If you set the bullets isSensor property to true, there will not be any force applied to the collision.

https://docs.coronalabs.com/api/type/Body/isSensor.html

Hi Alex, I’ve already set bullet.isSensor to true but the problem is still there. Moreover the force of the bullet seems to affect the shooter too.

Here is my code when I defined the bullet.

local bullet = display.newCircle(character.x,character.y,2) bullet:setFillColor(0,0,0) bullet.type = "bullet" bullet.isSensor = true physics.addBody(bullet) sceneGroup:insert(bullet) bullet:addEventListener("collision",function ( event ) if event.other.type == "monster" then display.remove(event.target) end end) bullet.isBullet = true

you must set isSensor *AFTER* calling addBody (or within the call, via the params) not before

Hi Dave, thanks to your reply, I can solve this problem now. Thank you very much.