Have user place 3d arkit object (swift4)

Right now in my ark app. My 3d object just shows up. I would like to have the user to be able to control where they place the object using the touches began function. I would like the user to be able to place the object as many times as they desired.

                   @IBOutlet var sceneView: ARSCNView!

    override func viewDidLoad() {
super.viewDidLoad()

// Set the view's delegate
sceneView.delegate = self

// Show statistics such as fps and timing information
sceneView.showsStatistics = true

// Create a new scene
let scene = SCNScene(named: "art.scnassets/dontCare.scn")!

// Set the scene to the view
sceneView.scene = scene
    }

    override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

// Create a session configuration
let configuration = ARWorldTrackingConfiguration()

// Run the view's session
sceneView.session.run(configuration)
    }

   override func viewWillDisappear(_ animated: Bool) {
       super.viewWillDisappear(animated)

// Pause the view's session
sceneView.session.pause()
  }


    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {


    }

Hi @timswift, thank you for posting on here. Have you checked out Apple’s sample code using ARKit? Handling 3D Interaction and UI Controls in Augmented Reality. Although their example doesn’t appear to use touchesBegan, it might be something worth reading through and possibly trying out.

Best,
Gina

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