0
votes

I have an SCNNode that has a camera named pointOfViewNode

whenever I push a button i call the function update camera in which I want the SCNNode to change its position to a focused target, however when I call this function the position does not change as desired, how can I make it to where I can?

func updateCamera()
{
    targetNode = SCNLookAtConstraint(target: planetNodeArray[currentFocusedElement])
    pointOfViewNode.constraints = [targetNode]
    //positions the camera node
    pointOfViewNode.position = SCNVector3(x: planetNodeArray[currentFocusedElement].position.x - 3 , y:planetNodeArray[currentFocusedElement].position.y + 65, z: planetNodeArray[currentFocusedElement].position.z + 2)
    pointOfViewNode.rotation = SCNVector4Make(1, 1, 1, -90)
    self.rootNode.addChildNode(pointOfViewNode)
    print(pointOfViewNode.position)
}
1

1 Answers

3
votes

I think instead of setting the pointOfView property on the SCNView you are just adding a node named pointOfViewNode.

Try this instead.

 self.scnView.pointOfView = someCameraNode;

Here is the relevant reference.