In my macCatalyst app, I try to make a SCNScene
where the user should be able to move around (with w, a, s and d) but It doesn't work.
I want
- to make the possibility to just move around in the scene first
- and then adjust it to the direction that the camera is facing
But I have already failed with the first step.
I tried to set the SCNView's point of view to a new SCNNode and tried to move that around:
// initializing the scene
let scene = SCNScene(named: "SceneKit Scene.scn")!
sceneView.scene = scene
// try to set the point of the scene
let node = SCNNode()
node.position = SCNVector3(x: 10, y: 10, z: 10)
sceneView.pointOfView = node
But it changed nothing.
I have also tried to move the node (that is holding all other nodes of the scene inside around)
override func pressesBegan(_ presses: Set<UIPress>,
with event: UIPressesEvent) {
guard let press = presses.first else { return }
guard let key = press.key else { return }
if key.charactersIgnoringModifiers == "w" {
node.position.z += 1
}
}
Which does work better, but it does not feel like going around in the scene, and if I move around the facing of the camera, I move into the wrong direction.
So how do I fix this?