I am able to track body motion using Arkit. In the session function on anchor update I get the anchor values. I need to update the anchor transform values in realtime so that the usdz shows the motion that I program and not the human tracked motion. How can we achieve this. The session function is below
func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
for anchor in anchors {
guard let bodyAnchor = anchor as? ARBodyAnchor else { continue }
let hipWorldPosition = bodyAnchor.transform
let skeleton = bodyAnchor.skeleton
let jointTransforms = skeleton.jointModelTransforms
for (i, jointTransform) in jointTransforms.enumerated() {
let parentIndex = skeleton.definition.parentIndices[i]
guard parentIndex != -1 else {continue}
let parentJointTransform = jointTransforms[parentIndex]
}
// Update the position of the character anchor's position.
let bodyPosition = simd_make_float3(bodyAnchor.transform.columns.3)
characterAnchor.position = bodyPosition + characterOffset
// Also copy over the rotation of the body anchor, because the skeleton's pose
// in the world is relative to the body anchor's rotation.
characterAnchor.orientation = Transform(matrix: bodyAnchor.transform).rotation
if let character = character, character.parent == nil {
characterAnchor.addChild(character)
//characterAnchor1.addChild(character1!)
}
}
}