3 Replies
      Latest reply on Dec 26, 2019 2:24 AM by bg2b
      pigmore Level 1 Level 1 (0 points)

        Here is my code:

         

        func didBegin(_ contact: SKPhysicsContact) {
        
          print("contact.bodyA.categoryBitMask:::\(contact.bodyA.categoryBitMask)")
          print("contact.bodyA.contactTestBitMask:::\(contact.bodyA.contactTestBitMask)")
          print("contact.bodyA.isDynamic:::\(contact.bodyA.isDynamic)")
          print("contact.bodyB.categoryBitMask:::\(contact.bodyB.categoryBitMask)")
          print("contact.bodyB.contactTestBitMask:::\(contact.bodyB.contactTestBitMask)")
          print("contact.bodyB.isDynamic:::\(contact.bodyB.isDynamic)")
        and I got the result:

        contact.bodyA.categoryBitMask:::1 contact.bodyA.contactTestBitMask:::9 contact.bodyA.isDynamic:::true contact.bodyB.categoryBitMask:::5 contact.bodyB.contactTestBitMask:::8 contact.bodyB.isDynamic:::false

        I found the contact nodes are not collected by its categoryBitMask and contactTestBitMask. I mean A's categoryBitMask not match B's contactTestBitMask, but their contact can be detect.

        Somebody tell me why, and how can I optimize the SKPhysicsContact.