I have an SKNode set up as the "world" node, inside of this node I have children like characters, environment etc..
I've set up the world node to have a physicsBody of edgeLoopFromPath (world.path), and a category bit mask of "world", however I'm not sure how collision detection works for edgeLoopFromPath, my collision function looks like this:
func didBeginContact(contact: SKPhysicsContact) {
if contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask {
firstBody = contact.bodyA
secondBody = contact.bodyB
} else {
firstBody = contact.bodyB
secondBody = contact.bodyA
}
if ((firstBody!.categoryBitMask == PhysicsCategory.Hero) &&
(secondBody!.categoryBitMask == PhysicsCategory.World)) {
heroDidCollideWithWorld(firstBody!.node!, world: secondBody!.node!);
}
}
theres more to the function but I want to keep it to the relevant portion, and the corresponding heroDidCollide function :
func heroDidCollideWithWorld(hero:SKNode, world:SKNode) {
(hero as Character).negativeEffect.runningSpeed = 0
}
however this isn't being hit. I have collision working for two bodies that are inside of the world node, but I can't figure out how to make the bodies inside the world node collide with the world (when they reach the edge of the node)