1

In SpriteKit, it's possible to move nodes by directly setting their velocity property.

This doesn't seem to work in SceneKit, however. Setting velocity -- both in game loop callbacks and outside of game loop functions -- seems to have no effect.

This answer from one of the Apple SceneKit engineers suggests accessing the velocity property is only possible during a game loop callback like updateAtTime.

So clearly there are limitations around the velocity property.

Is controlling the property directly not possible with SCNNodes?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Crashalot
  • 33,605
  • 61
  • 269
  • 439
  • Just now, first time, I've seen that this value is settable. https://developer.apple.com/reference/scenekit/scnphysicsbody/1514757-velocity Give me a few weeks to figure out how to setup a demoscene to test this, and I'll have a play with this. Without a programmer sitting next to me, I'm the world's slowest coder. – Confused Jan 29 '17 at 06:18
  • @Confused great find! reading through the notes it seems like it should work. will try again and report back. thanks! – Crashalot Jan 29 '17 at 09:41
  • @Confused found the answer, thanks for your help! – Crashalot Jan 29 '17 at 22:46
  • Well done! I didn't have a easy way to test it. Sorry. otherwise I would have done it. I am busy designing and writing at the moment... – Confused Jan 29 '17 at 23:53

1 Answers1

1

As @Confused kindly pointed out, the docs show it is possible to set velocity directly: https://developer.apple.com/reference/scenekit/scnphysicsbody/1514757-velocity

The key is to use a dynamic body type, not a kinematic one (and obviously not a static one).

Crashalot
  • 33,605
  • 61
  • 269
  • 439