I have this Spritekit project that I am working on where there is a player node that you move around the screen and then there are bullet nodes that shoot at you. My problem is that not only do the bullets hit the player, but they also hit each other. I have given the player and the bullets their own category/collision/contact masks.
I specify all the different category masks here(some of them can be ignored):
enum CategoryMask : UInt32 {
case playeragain = 11
case player = 1
case GBullet = 2
case BBullet = 3
case enemyships = 4
case coin = 5
case boss = 6
}
BBullet is the bullets that are shot at you and player is the node that the user controls.
I then assign these masks to each node:
player.physicsBody?.categoryBitMask = CategoryMask.player.rawValue
player.physicsBody?.collisionBitMask = CategoryMask.BBullet.rawValue | CategoryMask.coin.rawValue
player.physicsBody?.contactTestBitMask = CategoryMask.BBullet.rawValue | CategoryMask.coin.rawValue
bullet.physicsBody?.categoryBitMask = CategoryMask.BBullet.rawValue
bullet.physicsBody?.collisionBitMask = CategoryMask.player.rawValue
bullet.physicsBody?.contactTestBitMask = CategoryMask.player.rawValue
The collision between the bullets and the player works fine and I have set up how to handle each collision in the "Did begin contact" function. I would like to specify that I don't want the bullets to collide with each other.