I was looking to find a way to find out if my SKSpriteNode with an SKPhysicsBody is in motion.
I create a box, raise it above the bar, then set the bar and box masks to collide. The bar is pinned, but would love to know when the box stops bouncing.
A way would be to observe velocity. When it is zero, object is at rest. You need to detect it is really at rest and not just bouncing, by reading velocity at 2 close time points.
There is even a simpler way: use isResting property.
This property is automatically set to true by the physics simulation when it determines that the body is at rest. This means that the body is at rest on another body in the system. Resting bodies do not participate in the physics simulation until an impulse is applied to the object or another object collides with it. This improves the performance of the physics simulation. If all bodies in the world are resting, the entire simulation is at rest, reducing the number of calculations that are performed by the physics world.