Hello, I have two objects (blue, green) and two corresponding goals (blue, green) that they have to reach.
I have set up two filters for each of the objects and it works fine when they have to reach the desired goal; blue goes to blue, green goes to green.
Problem: I don’t want the blue and green objects to ignore each other (I want them to bounce off of each other if they hit), just the the goal that they don’t belong to.
Can anyone help?
[code]
– set the blue and green filters
local blueCollisionFilter = { categoryBits = 2, maskBits = 3 }
local greenCollisionFilter = { categoryBits = 4, maskBits = 5 }
– give each of the goals their filter
local goal = display.newImage( “obstacles/goal-small.png” )
physics.addBody( goal, “static”, { filter = blueCollisionFilter, radius = 20, isSensor = true } )
local goal2 = display.newImage( “obstacles/goal2.png” )
physics.addBody( goal2, “static”, { filter = greenCollisionFilter, radius = 20, isSensor = true } )
–
– HERE’S THE PROBLEM, because they have different filters, I still need the objects to interact with each other
blueObj = display.newImage(“balls/blue”)
physics.addBody( blueObj, “dynamic”, { density = 0, friction = 3, bounce = 0.1, radius = 14, filter = blueCollisionFilter } )
greenObj = display.newImage(“balls/green.png”)
physics.addBody( greenObj, “dynamic”, { density = 0, friction = 3, bounce = 0.1, radius = 14, filter = greenCollisionFilter } )
[/code] [import]uid: 42126 topic_id: 23592 reply_id: 323592[/import]