Ios 如何将实体移回其初始位置
对球施加线性脉冲和扭矩后,我试图将球移回初始位置 从Reality Composer加载场景后,我将球的初始变换存储在这里Ios 如何将实体移回其初始位置,ios,swift,arkit,realitykit,reality-composer,Ios,Swift,Arkit,Realitykit,Reality Composer,对球施加线性脉冲和扭矩后,我试图将球移回初始位置 从Reality Composer加载场景后,我将球的初始变换存储在这里 Experience.loadTestSphereAsync { (result) in switch result { case .success(let anchor): anchor.generateCollisionShapes(recursive: true)
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)
}
球不会回到原来的位置,而是冻结在原来的位置。将physicsBody模式改为.kinetic
将physicsBody模式改为.kinetic