Place multiple scn objects in touches began func

My swift code below uses func touchesBegan to place a scn object in the ARKit view. The problem is that it is only placing the object one time. I would like to create the code in a way that the user can select any area to place the scn object and it can place it as many times as they want too.

         class ViewController: UIViewController, ARSCNViewDelegate {
  @IBOutlet var sceneView: ARSCNView!
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

//Handle the shooting
     guard let frame = sceneView.session.currentFrame else { return }
       let camMatrix = SCNMatrix4(frame.camera.transform)
      let direction = SCNVector3Make(-camMatrix.m31 * 5.0, -camMatrix.m32 * 10.0, -camMatrix.m33 * 5.0)
        let position = SCNVector3Make(camMatrix.m41, camMatrix.m42, camMatrix.m43)
       let scene = SCNScene(named: "art.scnassets/dontCare.scn")!


      sceneView.scene = scene


        }

          }

@timswift Do you still have issues with this?

This topic was automatically closed after 166 days. New replies are no longer allowed.