1

I would like to move the camera around a SCNNode nodeA. What I'have done so far is:

self.cameraNode.constraints = [SCNLookAtConstraint(target: nodeA)]

now if I increment the position.x of the camera the camera still look toward the nodeA. How to move the camera around the nodeA (like the moon around the hearth)?

The camera should move along a circular orbit (just a circle, I'm not interested in elliptical orbit)

chiarotto.alessandro
  • 1,491
  • 1
  • 13
  • 31

1 Answers1

1

Add the moon as the child node of the earth. That way translating the earth won't affect the moon's relative position. You can find an example in the SceneKit Slides for WWDC 2014 sample code.

mnuages
  • 13,049
  • 2
  • 23
  • 40
  • Solved using SCNPhysicsHingeJoint – chiarotto.alessandro Aug 11 '15 at 19:51
  • you should not have to use physics for this. Simply adding a rotation animation to the right node should do. – mnuages Aug 12 '15 at 08:15
  • Yes but I have to change the pivot I think, the camera should rotate around a node. Using just animation rotation it rotate respect it's (local) origin – chiarotto.alessandro Aug 12 '15 at 08:28
  • you would have a *rotation* node with your camera node as a child node. You would translate the *camera* node so that it's at the desired distance, and you would animate the *rotation* node. That would achieve the same thing as changing the node's pivot. – mnuages Aug 12 '15 at 11:28
  • 1
    Yes i done in this way, but I have created another camera and I have changhed the point of view of the scene view. The WWDC slide are the best source to learn SceneKit. So many thanks – chiarotto.alessandro Aug 12 '15 at 14:33