Using custom Camera class in SceneKit


I am stuck on something and could use some help…
I have created a custom Camera class, I would like to add this class to my ViewController so I can load the same camera for all my levels.

I define the class as follows:

class GameCamera: SCNCamera {

let cameraNode: SCNNode!

override init() {
    cameraNode = SCNScene(named: "/GameAssets.scnassets/Camera.scn")?.rootNode.childNode(withName: "GameCamera", recursively: true)

func setup(scnView: SCNView) {
    cameraNode.position = SCNVector3(x: 0, y: 0, z: 0)


In the ViewController I then declare a variable and initialise with the class

private var camera = GameCamera()

And i then set up the camera…

camera.setup(scnView: self.scnView)

The camera seems to load, but I can’t seem to view through it. So the class is there but maybe the actual camera object is not loaded??

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

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