ios - SceneKit Apply Force in the Direction SCNode is Facing -


i have arkit (scenekit) application have car model. want apply force car direction car facing.

   func accelerate() {          // force should applied in direction.          let force = scnvector3(0,0,-1)         self.physicsbody?.applyforce(force, asimpulse: true)     }      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)     } 

the accelerate function 1 need implement can apply force in correct direction.

you should add invisible node in front of car child of car. way not move , have point of reference in front of car.


Comments

Popular posts from this blog

service - Android MediaPlayer calls onCompletion before it already finished -

javascript - Training Neural Network to play flappy bird with genetic algorithm - Why can't it learn? -

javascript - Create a stacked percentage column -