How to follow SCNNode with SCNCamera but don't rotate?

793 Views Asked by At

Im trying have my camera point at and follow the ship, but I don't want it to rotate when my ship rotates, how can I achieve this?

Code so far:

let targetNode = SCNLookAtConstraint(target: ship)
targetNode.gimbalLockEnabled = true
cameraNode.constraints = [targetNode]

ship.addChildNode(cameraNode)

//button click
SCNAction.rotateToX(0.0, y: 1.0, z: 0.0, duration: 0.5)

( both camera and ship rotate, but I would only like the ship to rotate. )

1

There are 1 best solutions below

0
On

Instead of making the cameraNode a child of the ship, you should update its position manually at each frame based on the ship's position.

I just posted an answer with a code sample right here.