0

I am trying to rotate a SCNNode with a JoyStick but when I use the .eulerAngles property the SCNNode doesn't seem to be affected by any physics. Thats why I want to use angularVelocity or angularVelocityFactor. Except there is another option.

Here I get the x and y values from my 2D JoyStick (touches moved function):

dx = base.position.x - ball.position.x
dy = base.position.y - ball.position.y
angle = atan2(dx, dy)

In the update function I set the velocity of the SCNNode (this is working):

playerNode.physicsBody!.velocity.x = Float(dx)/10
playerNode.physicsBody!.velocity.z = Float(dy)/10

What do I have to do to rotate my SCNNode in the same direction as the JoyStick.

Hal Mueller
  • 7,019
  • 2
  • 24
  • 42
  • What do you do that is not working? Have you read the documentation on [`SCNPhysicsBody`](https://developer.apple.com/documentation/scenekit/scnphysicsbody) and the **Physics and the Rendering Loop** chapter? It says that changing the transformation of a node resets its physics simulation and how to work around it. – jlsiewert Jul 16 '17 at 17:59
  • 1
    Possible duplicate of [Why SCNPhysicsBody resets position when set eulerAngles?](https://stackoverflow.com/questions/34092588/why-scnphysicsbody-resets-position-when-set-eulerangles) – Hal Mueller Jul 16 '17 at 23:21

0 Answers0