Hi
I have a physics body (bird) that when collides with another object (nut) the nut is removed.
What I want to stop happening is when the collision occurs sometimes the bird is affected by the collsion. I have tried setting the isSensor = true to bird but it only works some of the time. I may have five nuts in a row, some off nuts will effect / budge the bird.
–Bird
physics.addBody( bird ,“dynamic”, { density=1.0, friction=1, bounce=0, radius=20})\
–nuts
nut[i].type = “nuts”
nut[i].id = physics.addBody( ball[i] , “kinematic”,{density=0, friction=0, bounce=0, radius=20})
transition.to(nut[i], { time = 1500 + score, x =-100, y=cenerY})
nut[i].collision = myCollision
nut[i]:addEventListener(“collision”, nut[i])
local function myCollision(self, event)
if event.phase == “began” then
self.isSensor = true
if event.target.type == “nuts” and event.other.type == “bird” then
if (nut[event.target.id]) ~= nil then
nut[event.target.id] = nil – We remove object from table
event.target:removeSelf()
end
display.getCurrentStage():setFocus(nil)
end
elseif (event.phase == “ended”) then
self.isSensor = false
end
end