Double tap doesn't changes the cameras

On the page 66 is written: „Double-tap: If you have more than one camera, this switches between the cameras in your scene.”

I have added two cameras to the scene, but double tap doesn’t switch the view from one to another. It only resets the first camera. Any ideas how to change this?

Hi @mptaurus, could you show us how you are adding the two cameras? The book also mentions that double tapping will also resetting the camera so it sounds to me like the second camera might not be added correctly? Or maybe it’s in the same place?

Hope that helps! :slight_smile:

Hi. It is not in the same place. I added two cameras in GameViewController:

var cameraNode: SCNNode!
var cameraNode1: SCNNode!

// **then** 

override func viewDidLoad() {
    super.viewDidLoad()
    
   setupView()
   setupScene()
   setupCamera()
   testSTH()
}

func setupCamera() {
    cameraNode = SCNNode()
    cameraNode.camera = SCNCamera()
    cameraNode.camera?.fieldOfView = 60.0
    cameraNode.camera?.focusDistance = 20.0
    cameraNode.position = SCNVector3(x:0, y:5, z:10)
    scnScene.rootNode.addChildNode(cameraNode)
    scnView.pointOfView = cameraNode
    
    cameraNode1 = SCNNode()
    cameraNode1.camera = SCNCamera()
    cameraNode1.position = SCNVector3(x: 2, y: 5, z: 4)
    scnScene.rootNode.addChildNode(cameraNode1)
}

The same is true (double tap is not working) when I create two or more cameras in “visual” way in scn. file
Actually it worked in previous Xcode version but after upgrading to 9 it disappeared.

Hmmm i’m not too sure what the issue could be but I’ve invited @chrislanguage to the discussion as he should be able to help you :slight_smile:

Could you please also confirm that you’ve downloaded the latest copy of the book and project files that have been updated for Xcode 9/Swift 4/iOS 11?

Thanks :+1:

Yes I have downloaded the latest copy of the book and in fact I’ve expected to find there a solution … I also use newest MacBook Pro, Xcode 9.
Thanks

@chrislanguage Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi there,

The double tap feature is actually an undocumented feature, and it seems it’s now been removed. Apologies about that.

When your scene has more than one camera node in it, you can actually switch between multiple cameras views by setting the scnView.pointOfView = cameraNode (the camera node you want as the active view). This is actually explained in Chapter 7 of the book where the device orientation is changed from Portrait to Landscape mode.

So you can link the camera change to a double tap gesture event to achieve similar behaviour as before.

Hope that helps? :]

This topic was automatically closed after 166 days. New replies are no longer allowed.