0

I'm trying to figure out how to make a SCNNode rotate ONLY horizontally when a user is spinning the object in that way. Like spinning a basketball on your finger as an example. Is there a way to do that? I haven't been able to figure it out! Sorry if this sounds dumb! I'm new to SceneKit!

Thank you!

Hamish
  • 78,605
  • 19
  • 187
  • 280
Amit Kalra
  • 4,085
  • 6
  • 28
  • 44

1 Answers1

0

You want to apply torque in only the Y axis. See this diagram for the x, y, z axis rotations. https://stackoverflow.com/a/32707673

With your node (assuming you're using swift), you can use

let torque = SCNVector4(x: Float(0), y: Float(1), z: Float(0), w: Float(0.5)) node.physicsBody?.applyTorque(torque, asImpulse: true)

The last value in the SCNVector 4 is the magnitude, so play around with it to find a value that suits you

xta
  • 729
  • 2
  • 8
  • 29