在对球施加线性脉冲和扭矩后,我试图将球移回其初始位置。
从 Reality Composer 加载场景时,我将球的初始变换存储在此处
Experience.loadTestSphereAsync { (result) in
switch result {
case .success(let anchor):
anchor.generateCollisionShapes(recursive: true)
self.testSphereAnchor = anchor
self.ball?.physicsBody?.mode = .static
self.arView.scene.anchors.append(self.testSphereAnchor)
self.ballStartTransform = self.testSphereAnchor.ball?.transform
self.targetStartTransform = self.testSphereAnchor.target?.transform
self.addTapGestures()
case .failure(let error):
fatalError(error.localizedDescription)
}
}
要将球移回其原始位置,我正在这样做
func didPressRestartButton() {
ball?.clearForcesAndTorques()
ball?.physicsBody?.mode = .static
ball?.move(to: ballStartTransform!, relativeTo: nil, duration: 0.3)
}
球并没有回到原来的位置,而是冻结在它所在的位置。