0

I am trying to make my node start at the same position that I tap in a game but I can't figure it out

here is my code for where to position the node. I get my location from the tap gesture recognizer by:

let myLocation = recognizer.location(in: self.view)

Then I get the x and y position into a float value:

    let myx = Float(myLocation.x * 0.01)
    let myy = Float(myLocation.y * 0.01)

Then I set the nodes position(the camera is set at 30)

shapeNode.position = SCNVector3(x:myx, y:myy, z: 30.0)

The position is off by a lot and I can't figure out why...

Someone please help

Jordan Heath
  • 114
  • 8

1 Answers1

0

First you need to convert location from 2D on screen into 3D in real world using hittest() to place object in real world

Onur A.
  • 3,007
  • 3
  • 22
  • 37