I'm trying to build a game using ARkit and SceneKit, but after setting up the physicsWorld delegate and the physics body of the objects, the delegate method didBeginContact is not called.
This is my struct for physics body
struct CollisionCategory {
static let moltenBullet :Int = 4
static let iceShield :Int = 8
}
this is how I set the physics body
let collisionShape = SCNPhysicsShape(node: node, options: nil)
self.physicsBody = SCNPhysicsBody(type: .dynamic, shape: collisionShape)
self.physicsBody?.categoryBitMask = self.categoryMask
self.physicsBody?.contactTestBitMask = self.collisionMask
self.physicsBody?.collisionBitMask = self.collisionMask
I use self because it is the physics body of a custom class that inherit from SCNNode, collisionMask and categoryMask are setted in the constructor using the struct above.
In the didBeginContact I want to print something but nothing happens. I already setted the SCNPhysicsContactDelegate to
sceneView.scene.physicsWorld.contactDelegate
sceneView is ARSCNView.
I correctly see the shape of the physicsBody with
SCNDebugOptionShowPhysicsShape
Why is this happening ?
CollisionCategory
or a bullet and the shield to collide? – jlsiewert