Search code examples
swiftaugmented-realityrealitykitreality-composer

Reality Composer Tap Trigger issue


I'm new to Augmented Reality and I was going with Apple docs and WWDC videos to create my scene using Reality Composer simple blue ball that orbits around a white ball when I tap on blue ball but the tap trigger is not working when running on real device (iPhone 13) but working in Reality Composer, and here is the .rcproject url: https://filebin.net/asekvc7p9wt9ube8

enter image description here

class ViewController: UIViewController {

    let arVi = ARView()

    override func viewDidLoad() {
        super.viewDidLoad()

        let ar = try! orbits.loadScene()
        arVi.scene.anchors.append(ar)

        scannerView.addSubview(arVi)
        arVi.translatesAutoresizingMaskIntoConstraints = false
        arVi.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width).isActive = true
        arVi.heightAnchor.constraint(equalToConstant: UIScreen.main.bounds.height).isActive = true
        arVi.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
        arVi.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true

    }
}

Solution

  • i found the issue that the ArView was added to a scannerView which was a normal UIImageView deleting that image and adding the ArVIew to the main View make it work

    class ViewController: UIViewController {
    
    let arVi = ARView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
    
        let ar = try! orbits.loadScene()
        arVi.scene.anchors.append(ar)
    
        self.view.addSubview(arVi)
        arVi.translatesAutoresizingMaskIntoConstraints = false
        arVi.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width).isActive = true
        arVi.heightAnchor.constraint(equalToConstant: UIScreen.main.bounds.height).isActive = true
        arVi.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
        arVi.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
    
    }
    }