physics Collision

Hi All

I have sets of objects and all is perfectly working, Collision is fine between objects but because of the  physics when 2 of the ships occupy the same space there is a slight position change as if to move away from colliding, same happens when 2 bullets are in the same space!

i have added the physics to the arrays as below, any ideas? can i cut the physics out?

physics.addBody(Ships[numOfShips], {density = 1, friction = 0, bounce = 0});

physics.addBody(Bullets[numOfBullets], {density = 1, friction = 0, bounce = 0});

because i am using 2 arrays of objects i have set collision

function onCollision(event)

    if(event.object1.myName ==“bullets” and event.object2.myName ==“ships”) then

        

        event.object1:removeSelf()

        event.object1.myName=nil

        

        event.object2:removeSelf()

        event.object2.myName=nil

        

        print(#Bullets)

        print(#Ships)

    end

    if(event.object1.myName ==“ships” and event.object2.myName ==“bullets”) then

        

        event.object1:removeSelf()

        event.object1.myName=nil

        

        event.object2:removeSelf()

        event.object2.myName=nil

        

        print(#Bullets)

        print(#Ships)

    end

    

end

Runtime:addEventListener(“collision” , onCollision)

ok? anyone know if using

physics.addBody( rect, { isSensor = true } )

will still give me the collision options but allow objects to pass though each other?

Hey,

Yes, if you use isSensor = true then the ‘visible’ collision won’t happen but the “began” and “ended” collision events will still be fired.

Rich

Great stuff richieloco, thx for your help.

Works like a charm…

Great stuff :slight_smile:

ok? anyone know if using

physics.addBody( rect, { isSensor = true } )

will still give me the collision options but allow objects to pass though each other?

Hey,

Yes, if you use isSensor = true then the ‘visible’ collision won’t happen but the “began” and “ended” collision events will still be fired.

Rich

Great stuff richieloco, thx for your help.

Works like a charm…

Great stuff :slight_smile: