Xcode:13.1
iOS:15.1
USDZ:https://sketchfab.com/3d-models/spartan-armour-mkv-halo-reach-57070b2fd9ff472c8988e76d8c5cbe66
The animation can be played in iOS14, but after I update to iOS15, the animation cannot be played.
Thanks
import UIKit
import ARKit
import RealityKit
import Combine
class ViewController: UIViewController {
@IBOutlet var arView: ARView!
var rootAnchor: AnchorEntity!
override func viewDidLoad() {
super.viewDidLoad()
rootAnchor = AnchorEntity(plane: .horizontal)
arView.scene.addAnchor(rootAnchor)
var cancellable: AnyCancellable? = nil
cancellable = Entity.loadAsync(contentsOf: Bundle.main.url(forResource: "Spartan_Armour_MKV_-_Halo_Reach", withExtension: "usdz")!)
.sink(receiveCompletion: { error in
DispatchQueue.main.async {
cancellable?.cancel()
cancellable = nil
}
}, receiveValue: { [weak self] ey in
guard let self = self else { return }
self.rootAnchor.addChild(ey)
ey.availableAnimations.forEach {
ey.playAnimation($0.repeat())
}
DispatchQueue.main.async {
cancellable?.cancel()
cancellable = nil
}
})
}
}