Reputation: 55
class GameScene: SKScene, SKPhysicsContactDelegate {
func didBegin(_ contact: SKPhysicsContact) {
let contactA:SKPhysicsBody = contact.bodyA
let contactB:SKPhysicsBody = contact.bodyB
if contactA.contactTestBitMask == 1 && contactB.contactTestBitMask == 2 {
jumpButtonIsReady = true
print("player landed on ground1")
}
if contactA.contactTestBitMask == 2 && contactB.contactTestBitMask == 1 {
jumpButtonIsReady = true
print("player landed on ground1")
} }
}
I have used scene editor to set the contactTestBitMask of player to be 1 and the ground to be 2. they are both set to dynamic is true. But the contact is not registering. Thanks for any help.
Upvotes: 0
Views: 176
Reputation: 1979
Likely you are missing the physicsWorld.contactDelegate = self
in the scene initialization. Just conforming to SKPhysicsContactDelegate
is not sufficient.
If you verify that that's OK, then check that the physics bodies are correct by setting the view's showsPhysics
to true
.
Upvotes: 1