Working ARKit's MoCap solution

Here's my post where you'll find instructions how to create a .zshrc
file in macOS.
Load MoCap'ed model in RealityKit:
import RealityKit
import ARKit
class ViewController: UIViewController, ARSessionDelegate {
@IBOutlet var arView: ARView!
var character: Entity?
let characterAnchor = AnchorEntity()
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
arView.session.delegate = self
guard ARBodyTrackingConfiguration.isSupported
else { fatalError("MoCap is available on A12 & later") }
let config = ARBodyTrackingConfiguration()
arView.session.run(config)
arView.scene.addAnchor(characterAnchor)
character = try? Entity.load(named: "character")
}
func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
for anchor in anchors {
guard let bodyAnchor = anchor as? ARBodyAnchor
else { continue }
let bodyPosition = simd_make_float3(bodyAnchor.transform.columns.3)
characterAnchor.position = bodyPosition
characterAnchor.orientation = Transform(matrix: bodyAnchor.transform).rotation
if let character = character, character.parent == nil {
characterAnchor.addChild(character)
characterAnchor.scale = [0.02, 0.02, 0.02]
}
}
}
}