Local collision to interact with two or more objects?

I have this local collision code here

 local function goalCollision(event) local phase = event.phase local target = event.target local other = event.other if phase == "began" then if other.collisionType == "platform" then timer.performWithDelay(500, onBack ) lm.unlockNextLevel() end end end goal:addEventListener("collision", goalCollision)

Right now the collision event only occurs when the platform collides with the goal, I would like the collision event to occur with the goal when a few other objects collide it as well. I don’t want a global collision because not all objects on screen are to collide with the goal.

Cheers

Hi @darkspike119,

The solution to this is to use collision filters. That way, you define which objects can potentially collide with other objects, while telling other objects to ignore collisions.

There’s a useful chart-based setup outlined in this guide, so you can quickly determine the values you need:

https://docs.coronalabs.com/guide/physics/collisionDetection/index.html#collision-filter-worksheet

Hope this helps,

Brent

Hi @darkspike119,

The solution to this is to use collision filters. That way, you define which objects can potentially collide with other objects, while telling other objects to ignore collisions.

There’s a useful chart-based setup outlined in this guide, so you can quickly determine the values you need:

https://docs.coronalabs.com/guide/physics/collisionDetection/index.html#collision-filter-worksheet

Hope this helps,

Brent