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

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -