0

I'm trying to move SCNNode and I'm using this solution.

But when I do:

let start = sceneView.node(for: first)

my application freezes and Xcode doesn't do anything.

EDIT:

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)
} 
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220

0 Answers0