2

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

    }
}
belal medhat
  • 462
  • 1
  • 4
  • 18

2 Answers2

0

There might be five possible problems:


  1. You're trying to play behaviors on iOS Simulator:
    • Reality Composer Tap-behaviors can be run on a real device only.

  1. Collision boxes' interference:
    • After up-scaling, collision boxes of models intersect.

  1. Behaviors assigned incorrectly:
    • Check the Affected Objects of Trigger and Action Sequence.

  1. You do not follow Swift's naming convention:
    • Rename lowercased enum orbits to Orbits.

  1. Try not a Custom Behavior:
    • Choose Tap & Flip behavior, then replace its Action with Orbit.
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
0

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

}
}
belal medhat
  • 462
  • 1
  • 4
  • 18