2

I have a SCNPlane in SceneKit, which is rotated so it extends in the x and z directions, and I would like to have a UITapGestureRecognizer that can get me the x and z coordinates of a tap on that plane, so I can render something there.

I've been trying to use this StackOverflow question to solve this, but I can't seem to get it to work.

Community
  • 1
  • 1
Jack Maloney
  • 527
  • 2
  • 5
  • 18

1 Answers1

3

What you probably want is to do a hit test. It's essentially the same as unprojecting a point, except you get more information about where that hit line goes through and it goes beyond the first result.

That function will give you an array of results, you'll probably want only the first one. That will be a hit test result.

From that SCNHitTestResult, you can grab UV coordinates, or the localCoordinates which is probably what you are looking for.

Moustach
  • 2,904
  • 1
  • 13
  • 23