Not detecting collisions?

I set a collision filter for my game, and while some of them are working, others are not. Here’s the chart: 

The problem comes with the bullets. They *should* be colliding with the enemies, but they’re not. Any help? Did I do something wrong. Here’s the code where I call the filters:

[lua]

floorFilter = { categoryBits = 1, maskBits = 6 }

planeFilter = { categoryBits = 2, maskBits = 9 }

bulletFilter = { categoryBits = 4, maskBits = 10 }

enemyFilter = { categoryBits = 8, maskBits = 6 }

[/lua]

You might want to take a look at my collision helper library:

http://code.coronalabs.com/code/physics-collision-library

Using that library and your category and mask values, I wrote this code:

local floorCat, floorMask = collisionslib.getCategory("floor"), collisionslib.getMask("floor","plane","bullet") local planeCat, planeMask = collisionslib.getCategory("plane"), collisionslib.getMask("floor","enemy") local bulletCat, bulletMask = collisionslib.getCategory("bullet"), collisionslib.getMask("plane","enemy") local enemyCat, enemyMask = collisionslib.getCategory("enemy"), collisionslib.getMask("plane","bullet") print(floorCat/8,floorMask/8) print(planeCat/8,planeMask/8) print(bulletCat/8,bulletMask/8) print(enemyCat/8,enemyMask/8)

Dumping out the values to be used (with adjustments to align with regular bit flags), we get these categories and masks:

Floor: 1 7 Plane: 2 9 Bullet: 4 10 Enemy: 8 6

I already have all those values in my code (except floor, which isn’t mean to collide with itself), though. What does the library do differently? Everything but the bullet colliding with the enemy is working correctly.

EDIT: Changing the bullet physics body to “dynamic” seems to have worked.

I was going to ask what body types you had (and then forgot.) Certain body types won’t collide with others (which confuses many devs) but this actually makes really good sense and is part of Box2D’s logic, not Corona.

You might want to take a look at my collision helper library:

http://code.coronalabs.com/code/physics-collision-library

Using that library and your category and mask values, I wrote this code:

local floorCat, floorMask = collisionslib.getCategory("floor"), collisionslib.getMask("floor","plane","bullet") local planeCat, planeMask = collisionslib.getCategory("plane"), collisionslib.getMask("floor","enemy") local bulletCat, bulletMask = collisionslib.getCategory("bullet"), collisionslib.getMask("plane","enemy") local enemyCat, enemyMask = collisionslib.getCategory("enemy"), collisionslib.getMask("plane","bullet") print(floorCat/8,floorMask/8) print(planeCat/8,planeMask/8) print(bulletCat/8,bulletMask/8) print(enemyCat/8,enemyMask/8)

Dumping out the values to be used (with adjustments to align with regular bit flags), we get these categories and masks:

Floor: 1 7 Plane: 2 9 Bullet: 4 10 Enemy: 8 6

I already have all those values in my code (except floor, which isn’t mean to collide with itself), though. What does the library do differently? Everything but the bullet colliding with the enemy is working correctly.

EDIT: Changing the bullet physics body to “dynamic” seems to have worked.

I was going to ask what body types you had (and then forgot.) Certain body types won’t collide with others (which confuses many devs) but this actually makes really good sense and is part of Box2D’s logic, not Corona.