Search code examples
swiftscenekit

What method should I use instead of a deprecated 'resumeAnimation(forKey:)'?


When I'm using SceneKit's resumeAnimation(forKey:) instance method

model.resumeAnimation(forKey: "run")

Xcode 11.7 prints the following message:

//
//    'resumeAnimation(forKey:)' was deprecated in macOS 10.13: 
//     Use -[SCNAnimationPlayer setPaused:] instead.
// 

Question:

How to use [SCNAnimationPlayer setPaused:] instead of resumeAnimation(forKey:)?

(Available replacement has no argument with name key)


Solution

  • You can retrieve an SCNAnimationPlayer using animationPlayer(forKey:) and then set its paused property to true.