I have situation where I need to create two SKPhysicsBody for a single texture because the collision response need to be different
let leftBigBox = SKPhysicsBody(rectangleOf :CGSize(width: 490, height: 90) , center:bCenterPoint )
leftBigBox.contactTestBitMask = category_kitty
leftBigBox.categoryBitMask = category_train
leftBigBox.collisionBitMask = category_kitty | category_track
let rightSmallBox = SKPhysicsBody(rectangleOf :CGSize(width: 100, height: 45) , center:sCenterPoint )
rightSmallBox.categoryBitMask = category_wagon
rightSmallBox.collisionBitMask = category_kitty | category_track
rightSmallBox.contactTestBitMask = category_kitty
physicsBody=SKPhysicsBody(bodies: [leftBigBox,rightSmallBox])
but didBegin(_ contact: SKPhysicsContact)
does not detect when my kitty hits the child node. I can see the debug mode it is happening but the delegate won't print , if I specify the collisionBitMask
, contactTestBitMask
for the parent physicsBody it works but my goal is to split them into two
* I tried using joints and two different texture the performance is so bad
These are the values for kitty
physicsBody!.categoryBitMask = category_kitty
physicsBody!.contactTestBitMask = category_wagon | category_border | category_train
physicsBody!.collisionBitMask = category_border | category_wagon | category_train