Hello, I’m creating 3 physics bodies( A,B,C ), I want (A and B) not to collide with each others and in the same time they collide with the 3rd body ( C ).
How to achieve this using the physics.
Many Thanks. [import]uid: 43119 topic_id: 8810 reply_id: 308810[/import]
One way would be to add a type attribute to each item. So for instance:
local a = display.newImage("indeed.png")
a.type = "friend"
local b = dispaly.newImage("indeedyes.png")
b.type = "friend"
local c = display.newImage("indeedsir.png")
c.type = "enemy"
Then in your collision function, add this if statement:
if (e.phase == "began") then
if (e.other.type == "enemy") then
-- Do something
end
end
Thank you very much, I’ve been reading about ( Collision categories, masking, and groups) and i tried to implement this but didn’t success, Do you have any ideas about how to get it using this too?