I have a car model in ARKit application and I am able to rotate the car but now I want to apply force to the car so it can move in the direction it is facing.
Here is my code. the accelerate method is the one that I need to see what I can do with moving the car.
enum BodyType : Int {
case car = 1
case ground = 2
}
class Car :SCNNode {
var carNode :SCNNode
init(node: SCNNode) {
self.carNode = node
super.init()
setup()
}
private func setup() {
self.addChildNode(self.carNode)
/
self.physicsBody = SCNPhysicsBody(type: .dynamic, shape: nil)
self.physicsBody?.categoryBitMask = BodyType.car.rawValue
}
func accelerate() {
/
}
func turnRight() {
self.physicsBody?.applyTorque(SCNVector4(0,1.0,0,-0.1), asImpulse: true)
}
func turnLeft() {
self.physicsBody?.applyTorque(SCNVector4(0,1.0,0,0.1), asImpulse: true)
}Any ideas?