Create a local collision event that removes a physics body?

How would I do this using this local collision code

local function goalCollision(event) local phase = event.phase local target = event.target local other = event.other if phase == "began" then if other.collisionType == "eggplant" then composer.gotoScene("chooselevel") end end end goal:addEventListener("collision", goalCollision)

Rather than composer going to the scene “chooselevel”, could I make it remove an object?

Can you post the code if the objects that are colliding? 

I don’t remember off the top of head you remove physics bodies during collision ( I know you cannot move them)

Try (put this where go to scene is)

timer.performWithDelay(100, function()
display.remove(myObj)
end)

Yes, you can remove an object during a collision (same time-step). :slight_smile:

The list of what you can’t do during a collision time-step is documented here, for everybody’s reference (within the “Global Collision Handling” section):

https://docs.coronalabs.com/guide/physics/collisionDetection/index.html

Brent

Can you post the code if the objects that are colliding? 

I don’t remember off the top of head you remove physics bodies during collision ( I know you cannot move them)

Try (put this where go to scene is)

timer.performWithDelay(100, function()
display.remove(myObj)
end)

Yes, you can remove an object during a collision (same time-step). :slight_smile:

The list of what you can’t do during a collision time-step is documented here, for everybody’s reference (within the “Global Collision Handling” section):

https://docs.coronalabs.com/guide/physics/collisionDetection/index.html

Brent