我正试图移动SCNNode
而我正在使用this solution。
但是当我这样做时:
let start = sceneView.node(for: first)
我的应用程序死机,Xcode没有做任何事情。
修改
func startBouncing(time: TimeInterval) {
guard let sceneView = self.view as? ARSCNView,
let first = anchors.first,
let start = sceneView.node(for: first),
let last = anchors.last,
let end = sceneView.node(for: last)
else { return }
if ballNode.parent == nil {
sceneView.scene.rootNode.addChildNode(ballNode)
}
let animation = CABasicAnimation(keyPath: #keyPath(SCNNode.transform))
animation.fromValue = start.transform
animation.toValue = end.transform
animation.duration = time
animation.autoreverses = true
animation.repeatCount = .infinity
ballNode.removeAllAnimations()
ballNode.addAnimation(animation, forKey: nil)
}