Physics removeBody

I have two physics objects that will collide eventually. One of those has this property:

.isSensor = true.

I would like to remove one of the body when these objects collide, but having this error:

“physics.removeBody() cannot be called when the world is locked and in the middle of number crunching, such as during a collision event”

I saw in some posts that removeBody is better used with some delay so the physics is done.

My questions is: 

My two objects will collide but will maintain position, so the event on the function will never reach the “ended” state. So i want to removeBody of one of those objects while colliding. Is it possible? 

do this:

timer.performWithDelay(1, function() physics.removeBody( obj ) end )

, where obj is the handle of the object to remove.

You cannot add or remove a physics body during a collision.

Wow, worked like a charm.

thought it would work only with the “ended” phase…

Thank you!

do this:

timer.performWithDelay(1, function() physics.removeBody( obj ) end )

, where obj is the handle of the object to remove.

You cannot add or remove a physics body during a collision.

Wow, worked like a charm.

thought it would work only with the “ended” phase…

Thank you!