SKNodes not touchable inside SCNPlane

Hello,


I am having a problem with the scene kit nodes that are not touchable.

My setup is the following:

- I have a ARKit project with SceneKit

- I am using ARSCNViewDelegate methods to detect when a AR image is recognized whitin a AR capture

- when such image is detected I am placig a SpriteKit on top of this iamge, using a SCNPlane that has as "diffuse.contents" my custom spirte kit scene

- everything is fine, but my scene does not get touch events; neither the nodes

- the only way I can interact witht he nodes is through the ViewControllers touch callbacks like this:

- I get a touch on the view controller

- I get the location inside the Scene Kit view

- then I use hitTest to get a result inside the scene kit

- if I get a result on the hit testing, I get the coordinates inside the diffuse mapping channel and use them to get the nodes at that location

My code is something like this:

private func processTap(_ touch: UITouch) {

let point = touch.location(in: getSceneView())

guard let hitTestResult = getSceneView().hitTest(point, options: nil).first else { return }

guard let channel = hitTestResult.node.geometry?.firstMaterial?.diffuse.mappingChannel else { return }

let coordinates = hitTestResult.textureCoordinates(withMappingChannel: channel)

let mapScenePoint = CGPoint(x: coordinates.x * mapScene.size.width, y: coordinates.y * mapScene.size.height)

mySpriteKitScene.processTap(for: mapScenePoint)

}


Maybe there is something I could do to have my sprite scene touchable. Or its nodes.


Any ideas?


Thanks!

Replies

Take a look at this thread:

https://forums.developer.apple.com/thread/79674