Search code examples
scenekitscnnodescntext

SKLabelNode Hit Test


When conducting a hit test on an ARSCNView containing SCNNodes with SCNText geometry, it appears that the hit test will only be successful if the point tested lies inside a letter in the SCNText.

This is not optimal, as it makes the nodes harder to tap. Is there a way to change the "hit box" so that the hit test will be successful if the tested point lies anywhere inside the bounds of the SCNNode? I am trying to avoid the case where the hit test is unsuccessful if the user's tap lies in-between two letters in the SCNText.


Solution

  • I resolved my problem by setting the SCNHitTestOption.boundingBoxOnly option to true. This will conduct the hit test ignoring the node's geometry.

    let hitTestResults = sceneView.hitTest(tapPoint, options: [.boundingBoxOnly: true])