Collision Filters not working

Hi i am trying to get this collision filter to work but i am a little bit stuck…

[code]local bad1CollisionFilter1 = { categoryBits = 1, maskBits = 3 }

if ( temp.imgpath == “BCloud1.png” ) then
physics.addBody( randomStar, { density=2.9, friction=0.5, bounce=0.3, radius=16, filter=bad1CollisionFilter1 } )
end

local collision = function( bad1CollisionFilter1 )
if bad1CollisionFilter1.phase == ‘began’ then
print(“Hello i am CollisionFilter1”)
end
end[/code]

Any help to get this working is appreciated! [import]uid: 225288 topic_id: 37275 reply_id: 67275[/import]

Hi mmk.verheijden,

Did you follow through the entire collision filter process at the following link? It requires a “both ways” approach (on both colliding filters).

http://developer.coronalabs.com/forum/2010/10/25/collision-filters-helper-chart

Brent [import]uid: 200026 topic_id: 37275 reply_id: 145508[/import]

  • [import]uid: 225288 topic_id: 37275 reply_id: 145559[/import]

i’m trying to but struggle with it if i add a event listener for collision

Runtime:addEventListener("bad1CollisionFilter1", collision)  

i’m trying to but struggle with it if i add [import]uid: 225288 topic_id: 37275 reply_id: 145558[/import]

Hi @mmk.verheijden,
Your code above looks proper, so I’m not sure what the issue is. If you’re following the collision filters guide exactly as stated, this should be working. What are these “randomStar” objects colliding with? Other “randomStar” objects, or different objects entirely? Do those other objects have the appropriate collision filters specified too?

Brent [import]uid: 200026 topic_id: 37275 reply_id: 145653[/import]

Hi mmk.verheijden,

Did you follow through the entire collision filter process at the following link? It requires a “both ways” approach (on both colliding filters).

http://developer.coronalabs.com/forum/2010/10/25/collision-filters-helper-chart

Brent [import]uid: 200026 topic_id: 37275 reply_id: 145508[/import]

  • [import]uid: 225288 topic_id: 37275 reply_id: 145559[/import]

i’m trying to but struggle with it if i add a event listener for collision

Runtime:addEventListener("bad1CollisionFilter1", collision)  

i’m trying to but struggle with it if i add [import]uid: 225288 topic_id: 37275 reply_id: 145558[/import]

Hi @mmk.verheijden,
Your code above looks proper, so I’m not sure what the issue is. If you’re following the collision filters guide exactly as stated, this should be working. What are these “randomStar” objects colliding with? Other “randomStar” objects, or different objects entirely? Do those other objects have the appropriate collision filters specified too?

Brent [import]uid: 200026 topic_id: 37275 reply_id: 145653[/import]