I am trying to determine if there is a possible contact in the path of rotating a node. My idea is to do an incremented rotation (for 90 deg i loop 10 times 9 degrees) and perform contact test each time. My issue is that even tho i am calling updateCollisionPairs() each time, the contacts are empty even when there is an object in the path. Here is a picture that illustrate it somehow (front facing):
I'm trying to rotate node A by 90 degrees, but before i need to check if the "path is clear" - in this case the node B is in the way so i'm expecting to get a hit with one or more of the incremental rotations.
Node A and Node B are both type .kinematic, with categoryBitMask 2
Normaly i am doing contact testing in the render loop (willRenderScene) after the physicsWorld simulation is updated, and this triggers fine, so i know my physicsBodies & contactBitmasks are set correctly, but in this specific case i can't wait for another loop to perform the contact detection for obvious reasons.
Code i tried so far:
for i in 1...10 {
nodeA.transform = SCNMatrix4Mult(nodeA.transform, SCNMatrix4MakeRotation(GameHelper.deg2rad(deg:90)/10, 0, 0, 1))
nodeA.physicsBody.resetTransform()
self.scnScene.physicsWorld.updateCollisionPairs()
let contacts = self.scnScene.physicsWorld.contactTest(with: (nodeA.physicsBody)!, options: [SCNPhysicsWorld.TestOption.collisionBitMask:2])
print(contacts)
if contacts.count > 0 {
print("CONTACT !!!!")
}
}