I want to detect when an SCNNode stops moving in my Scenekit game written in swift.
I have a floor with a node falling towards it by gravity. the node hits the floor, bounces and then lands and settles in a stationary position.
I need to add a function that watches the SCNNode and does something when it comes to rest.
In the final game i will have different SCNNodes falling at different speeds and so need a function that relies solely on looking at the motion of the node rather than waiting for a set time.
Is there anything built in to scenekit that would be of use? If not is there anyway to use some form of timer to call a function every half second? how would i set up a timer and how would i check the SCNNode to see if it has stopped moving?
EDIT:
As was pointed out, my question is the same as SceneKit SCNPhysicsBody get notified of resting. that questioner was using obj-c though and im using swift. i found that the answer in a comment here seems much better and worked for me.