Scene Kit automatically updates the position of the node that owns an SCNPhysicsBody
based on the physics simulation, so SCNNode.position
is the right property to look for.
The catch is that there are actually two versions of that node in play. The one you typically access is called the "model" node. It reflects the target values for properties you set, even if you set those properties through an animation. The presentationNode
reflects the state of the node currently being rendered — if an animation is in progress, the node's properties have intermediate values, not the target values of the animation.
Actions, physics, constraints, and any scene graph changes you make inside update/render loop methods directly target the "presentation" version of your scene graph. So, to read node properties that have been set by the physics simulation, get the presentationNode
for the node you're interested in (the node that owns the vehicle's chassisBody
physics body), then read the presentation node's position
(or other properties).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…