I tried a few different ways to print the location of the ball while the game is running, but it is always equal to the original position even though I see the ball moving around the screen. But I can print the location of the contact in the delegate method ‘physicsWorld(world: contact:)’ and get reasonable coordinates.
One way I tried to print the ball location is by adding statements to ‘physicsWorld(world: contact:)’ so the first part of it is:
func physicsWorld(world: SCNPhysicsWorld, didBeginContact contact: SCNPhysicsContact) {
print(“contact at: \(contact.contactPoint)”) // A
var contactNode: SCNNode!
var ball: SCNNode!
if contact.nodeA.name == “Ball” {
ball = contact.nodeA
contactNode = contact.nodeB
} else {
ball = contact.nodeB
contactNode = contact.nodeA
}
let loc = ball.position
print(“ball x, y: \(loc.x), \(loc.y)”) // B
The coordinates printed at //A look good but the coordinates printed at //B are always equal to the original coordinates of the ball in Game.scn.
Why is that?