I have a game in Spritekit, the car is a SKSpriteNode, the line is SKShapeNode.
As you can see from the first gif, when I draw an X at the top so that the car falls with low speed, it works fine, but then drawing an X lower (2nd gif) so the car has more speed, it will cause the car to pass through the lines and behave erratically.
My understanding is this is the result of not meeting the collision threshold, the car is traveling faster than the systems ability to catch it.
What are my options here, I tried adding usesPreciseCollisionDetection, but that didn't help. Neither did adjusting the speed on the carNode nor setting the view preferredFramesPerSecond to 90.
What do I need to add to get proper collision when my node is traveling fast?
var carNode: SKSpriteNode!
var lineNode: SKShapeNode?
override func didMove(to view: SKView) {
...
carNode = SKSpriteNode(texture: carTexture, size: carSize)
carNode.physicsBody = SKPhysicsBody(rectangleOf: carNode.size)
carNode.physicsBody?.categoryBitMask = 1
carNode.physicsBody?.collisionBitMask = 2
carNode.physicsBody?.contactTestBitMask = 2
carNode.physicsBody?.angularDamping = 0.5
...
addChild(carNode)
...
}
...
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
...
let newLine = SKShapeNode()
...
addChild(newLine)
lineNode = newLine
updateLine(to: touchLocation!)
}
...
func updateLine(to position: CGPoint) {
let physicsBody = SKPhysicsBody(edgeChainFrom: line.path!)
physicsBody.categoryBitMask = 2
physicsBody.collisionBitMask = 1
physicsBody.contactTestBitMask = 2
line.physicsBody = physicsBody
...
}

