I’m working on a SceneKit project where I need to create dynamic toruses with holes that can collide with each other. I’ve tried setting up the physics bodies for these toruses using both convexHull and concavePolyhedron shapes. While I can successfully create the toruses with holes using concavePolyhedron, I’m facing an issue where these toruses do not collide with each other.
Here’s a brief overview of what I’ve implemented:
// Creating the torus geometry
let torus = SCNTorus(ringRadius: 1.0, pipeRadius: 0.3)
torus.firstMaterial?.diffuse.contents = UIColor.blue
// Setting up the physics body
let shapeOptions = [SCNPhysicsShape.Option.type: SCNPhysicsShape.ShapeType.concavePolyhedron]
let physicsShape = SCNPhysicsShape(node: torusNode, options: shapeOptions)
let physicsBody = SCNPhysicsBody(type: .dynamic, shape: physicsShape)
torusNode.physicsBody = physicsBody
// Scene setup
scene.rootNode.addChildNode(torusNode)
Even though I’ve set the physics body type to dynamic and used concavePolyhedron, the toruses pass through each other without any collision. I need the toruses to be dynamic and collidable, ideally with accurate collision detection considering their hollow shapes.
Has anyone encountered this issue before, or can suggest a way to get accurate collision detection for dynamic toruses in SceneKit?