So. I'm attempting to create an SCNPhysicsVehicle in SceneKit. The problem I am getting is that the vehicle chassis does collide with the floor in my scene, although the wheels don't. The wheels just go straight through the floor until the chassis collides with the floor. I was wondering whether there was some thing I am forgetting? I have never seen anyone else set a collision category or category bit mask for the wheels on an SCNPhysicsVehicle. With that being said, I did even try that but no luck!
Very big thanks in advance.
let carScene = SCNScene(named: "art.scnassets/Textures/rc_car.dae") //rc_car.dae
let chassisNode = carScene!.rootNode.childNode(withName: "rccarBody", recursively: true)!
chassisNode.position = SCNVector3Make(0, 10, -30)
let body = SCNPhysicsBody.dynamic()
body.allowsResting = false
body.mass = 80
body.restitution = 0.1
body.friction = 0.5
body.rollingFriction = 0
chassisNode.physicsBody = body
scene.rootNode.addChildNode(chassisNode)
let wheelnode0 = chassisNode
.childNode(withName: "wheelLocator_FL", recursively: true)!
let wheelnode1 = chassisNode
.childNode(withName: "wheelLocator_FR", recursively: true)!
let wheelnode2 = chassisNode
.childNode(withName: "wheelLocator_RL", recursively: true)!
let wheelnode3 = chassisNode
.childNode(withName: "wheelLocator_RR", recursively: true)!
let wheel0 = SCNPhysicsVehicleWheel(node: wheelnode0)
let wheel1 = SCNPhysicsVehicleWheel(node: wheelnode1)
let wheel2 = SCNPhysicsVehicleWheel(node: wheelnode2)
let wheel3 = SCNPhysicsVehicleWheel(node: wheelnode3)
vehicle = SCNPhysicsVehicle(chassisBody: chassisNode.physicsBody!,
wheels: [wheel0, wheel1, wheel2, wheel3])
chassisNode.physicsBody?.collisionBitMask = USBitMaskManager.boundary | USBitMaskManager.sphere
chassisNode.physicsBody?.categoryBitMask = USBitMaskManager.sphere
// scene.physicsWorld.addBehavior(vehicle)
return vehicle