Hi, i'm new in xcode and swift and I tried to add gestures to my AR View. But it failed. I can see the modell (a helix) when opening with my iPhone and move around but I can't rotate the modell with my fingers. I didn't get any error message in xcode.
TestSpiral is a simple .rcproject file I generated in RealityComposer.
I use xcode 12.4.
Thanks for your help.
Sorry. I tried to attach the project but this is not possible. This is the code:
code-block
import UIKit
import RealityKit
import ARKit
import SceneKit
class ViewController: UIViewController {
@IBOutlet var gestureRecognizer: UIRotationGestureRecognizer!
// DECLARE VARIABLE MODELANCHOR
var modelAnchor: TestSpiral.MainScene?
// ALLOW INTERACTION
var isUserInteractionEnabled = Bool (true)
// DECLARE VARIABLE ARVIEW
@IBOutlet weak var sceneView: ARView!
override func viewDidLoad() {
super.viewDidLoad()
// GESTURE ROTATION
func rotatePiece(_ gestureRecognizer: UIRotationGestureRecognizer) {
guard gestureRecognizer.view != nil else {return}
if gestureRecognizer.state == .began || gestureRecognizer.state == .changed {
gestureRecognizer.view?.transform = gestureRecognizer.view!.transform.rotated(by: gestureRecognizer.rotation)
gestureRecognizer.rotation = 0
}}
// LOAD MODELL
modelAnchor = try! TestSpiral.loadMainScene()
sceneView.scene.anchors.append(modelAnchor!)
}
}