2

I am trying to get notified when the body stops rolling over.

After this post was trying to add some observers for SCNPhysicsBody. However, since I am new to iOS development, did smth wrong and don't know how to add an observer for this kind of properties.

In viewDidLoad():

body.physicsBody!.addObserver(self, forKeyPath: #keyPath(SCNPhysicsBody.isResting), options: [.new, .old], context: nil)

And func

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {     
    print("resting")
}

Also tried to put only this line in viewDidLoad():

body.physicsBody!.observe(\.isResting, changeHandler: { (_, _) in
    print("resting")
})

Nothing printed

unknown
  • 23
  • 6
  • I still don't know how to add an observer for the properties of the framework, so this is just a comment. To get notified of body rest, I added protocol SCNSceneRendererDelegate and func renderer(_:,didSimulatePhysicsAtTime:) where I checked whether the body is resting. – unknown Jun 17 '19 at 06:42

0 Answers0