3

I am trying to make an app that uses 3D physics and detects when the various nodes in the scene have all come to rest. The logical way to do this would seem to be testing their isResting property on their physics body. However, no matter how stationary the objects are, this value is never set. I have checked that allowsResting is true and am testing the attribute as follows, but I have never seen even one object 'at rest' despite logging out its status on each update. I've also tried putting this in the didRender function. Anyone got any ideas as to why isResting never seems to be set?

var isTotallyAtRest = false

func renderer(aRenderer: SCNSceneRenderer, didSimulatePhysicsAtTime time: NSTimeInterval) {
        for object in allObjects {
            if let physics = object {
                if physics.isResting == false {return}
            }
        }
        isTotallyAtRest = true
    }
Ash
  • 9,064
  • 3
  • 48
  • 59
  • is *any* body resting? How are configured those that are never resting? – mnuages Aug 12 '15 at 12:10
  • I think the issue is that, while the bodies are at rest, they are at rest because they have come into contact with the ground. Although they are not moving, forces are still acting upon them (the force of gravity being cancelled out by the upward force of the ground plane) therefore they are never at rest. Can anyone confirm this? – Ash Aug 12 '15 at 15:59
  • 1
    According to physics, a body is at rest when it is sitting on a ground plane. It has nothing to do with force. I don't see why this isn't true for scenekit. – Joel Teply Oct 16 '17 at 20:36
  • From a scientific standpoint I agree, but that doesn't necessarily mean that this is a parameter handled by the system. It could be that SceneKit expects this value to be set manually, i.e. when a certain amount of time has passed without movement occurring, and that doing so informs the physics system not to act upon that solid for the time being. However it's been too long since I wrote this ticket and I do not recall the details of the project. – Ash Oct 17 '17 at 07:59
  • @JoelTeply Thanks. comment helped to solve the problem. – Nazmul Hasan May 01 '18 at 02:59
  • @NazmulHasan How did you solve the issue? I have nodes stationary on floor, that are not being registered as resting. – Yarn May 07 '18 at 15:07

0 Answers0