Group Group Group Group Group Group Group Group Group

SceneKit: SCNAnimationPlayer re-trigger animationDidStop


#1

I have this code:

var animationPlayer = loadAnimationFrom("ANIMATION_TO_LOAD")
animationPlayer.animation.isRemovedOnCompletion = false
animationPlayer.animation.animationDidStop = { [unowned self] (_, _, _) in
 // execute when animation end
}

When i execute play animationPlayer.play(). The animation works and it trigger animationDidStop. The problem is when i call animationPlayer.play() again, animationDidStop don’t get call no more.


#2

@chrislanguage Can you please help with this when you get a chance? Thank you - much appreciated! :]


#3

What I end up doing is instead of listening for animationDidStop, once I trigger play is this:

animationPlayer.play()
DispatchQueue.main.asyncAfter(deadline: .now() + animationPlayer.animation.duration, execute: {
// execute when animation end
})