0

I have a sceneKit app for iOS. I have an SCNPhysicsBody attached to an SCNNode. I set the .physicsBody to nil, make some changes the SCNNode and then set the .physicsBody to a new SCNPhysicsBody or to a copy of the original SCNPhysicsBody. In either case, the SCNNode resets its position to its initial position.

How can I reset the .physicsBody and keep the SCNNode in the same position so it continues on its trajectory?

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
Howard Shere
  • 143
  • 1
  • 7

1 Answers1

1

When your physics affects node position its original position (that was assigned to node position property) stays same, presentation node position is changed. All transformations (rotation/scale/translate) works that way.

So you can do something something like this pseudocode:

// 1. remember position of presentation node
var position = node.presentation.position;
// 2. do some changes on node, physics body, whatever
// 3. restore position (without losing original node position)
your_node.presentation.position = position
// ... or apply presentation position to original position
your_node.position = position
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Ef Dot
  • 768
  • 6
  • 18