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