I have a red SCNNode
that 1/2 way hovers over a blue SCNNode
. I need the dragEvent for both of them so when they are swiped they move (which works fine). The thing is I only need the tapEvent for the blue node.
I tried to follow this answer here to return nil
if the red node is tapped so that it can continue on to the blue node. It's unable to return nil because there isn't a return value: Unexpected non-void return value in void function
.
if hitResult.node.name == "Red" {
return nil // Unexpected non-void return value in void function
}
if hitResult.node.name == "Blue" {
// do something
}
How can I ignore the touch event when the red node is tapped and continue the touch event to the blue node underneath of it?
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(nodeWasTapped(_:)))
sceneView.addGestureRecognizer(tapGesture)
func nodeWasTapped(_ recognizer: UITapGestureRecognizer) {
guard let sceneView = recognizer.view as? ARSCNView else { return }
let touchLocation: CGPoint = recognizer.location(in: sceneView)
let hitResults = sceneView.hitTest(touchLocation, options: [:])
if !hitResults.isEmpty {
guard let hitResult = hitResults.first else { return }
if hitResult.node.name == "Red" {
// *** ignore this tap and continue to the blue node ***
}
if hitResult.node.name == "Blue" {
// do something
}
}
}