destroy physics object on collision ?
destroy physics object on collision ?
For example, I have a physics rectangle and 10 physics circle, every time the rectangle touches the circle, the circle will be destroyed, to check contact I use world:setCallbacks on load function and use beginContact function to check the collision, tried it.. and every time the rectangle collide with the circle, 1 or more circle will disappear.. anyone know how to fix this ?
-
Re: destroy physics object on collision ?
If I understand your problem, then you should check which circle you hit in your update function and then remove it. ex:
Code: Select all
for i,c in ipairs(circles) do
if c.x is colliding with my player then
table.remove(circles, i)
end
end
Re: destroy physics object on collision ?
you mean.. check all of them manually ? like c.x = player.x and c.y = player.y ? i dont really like to use thatxNick1 wrote: ↑Mon Jun 19, 2017 1:21 pm If I understand your problem, then you should check which circle you hit in your update function and then remove it. ex:Code: Select all
for i,c in ipairs(circles) do if c.x is colliding with my player then table.remove(circles, i) end end
-
Who is online
Users browsing this forum: Bing [Bot] and 3 guests