I have 2 scene that i drag into a new scene please see image for the setup.
What i’m trying to do is to move position of the Large_Needle
with panning.
I’m referencing the large needle node like this:
var largeNeedle: SCNNode!
largeNeedle = scene.rootNode.childNode(withName: "Large_Needle", recursively: true)
Pan Gesture recognition and handler
let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.handlePanning(pan:)))
self.sceneView.addGestureRecognizer(panGestureRecognizer)
@objc func handlePanning(pan: UIPanGestureRecognizer) {
let touchPoint = pan.location(in: sceneView)
if let hit = sceneView.hitTest(touchPoint, options: nil).first {
if let name = hit.node.name {
if name == "Large_Needle_Cap" || name == "Large_Needle" {
let yPan = pan.velocity(in: sceneView).y/10000
largeNeedle.runAction(SCNAction.moveBy(x: 0, y: yPan, z: 0, duration: 0.1))
}
}
}
}
But for some reason, the position of it don’t update. I also try using largeNeedle.position = SCNVector3(0, yoffset, 0)
don’t work also. Can anyone tell me why it’s not working?