Crashalot
Crashalot

Reputation: 34523

SceneKit: move SCNNode by setting velocity property directly like in SpriteKit?

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?

Upvotes: 1

Views: 548

Answers (1)

Crashalot
Crashalot

Reputation: 34523

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).

Upvotes: 1

Related Questions