Stop physics on object after collision

I’m shooting an object towards a wall. When it hits the wall it should stick on to the wall and be removed from the physics engine.

No matter what I try I get an error from the physics engine saying that number crunching is still going on.

How can i achieve this?

Thanks
[import]uid: 124497 topic_id: 22548 reply_id: 322548[/import]

It could be a few things most likely your not using a Phase during the event. This is how i remove Physics objects onCollision.

[lua]function onCollision(evt)

if ( evt.phase == “began” ) – Use phase began

local obj = evt.object1

if obj.isRemoveing then return end –
obj.isRemoveing = true
obj:setLinearVelocity( 0, 0) – Stop the Objects Velocity
obj.bodyType = “kinematic” – Body type to Kinematic

timer.performWithDelay(1,function() – Wait 1 frame

obj:removeSelf() – Remove Object
obj=nil

end,1)

end

end [import]uid: 7177 topic_id: 22548 reply_id: 89892[/import]

Thanks for the answer. Do I have to kill the whole object?

I just want to remove the connection to the physics engine but keep the object on stage. [import]uid: 124497 topic_id: 22548 reply_id: 89894[/import]

You don’t have to use removeSelf().

I have more luck using (obj.isSensor = true) rather then removing the body with physics.removeBody( obj ) i would test both.
[import]uid: 7177 topic_id: 22548 reply_id: 89896[/import]