简体   繁体   English

SceneKit:像在 SpriteKit 中一样通过直接设置速度属性来移动 SCNNode?

[英]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.在 SpriteKit 中,可以通过直接设置节点的velocity属性来移动节点。

This doesn't seem to work in SceneKit, however.然而,这在 SceneKit 中似乎不起作用。 Setting velocity -- both in game loop callbacks and outside of game loop functions -- seems to have no effect.设置velocity ——无论是在游戏循环回调中还是在游戏循环函数之外——似乎都没有效果。

This answer from one of the Apple SceneKit engineers suggests accessing the velocity property is only possible during a game loop callback like updateAtTime .来自 Apple SceneKit 工程师之一的这个回答表明,只有在像updateAtTime这样的游戏循环回调期间才能访问速度属性。

So clearly there are limitations around the velocity property.很明显, velocity属性存在局限性。

Is controlling the property directly not possible with SCNNodes?使用 SCNNodes 无法直接控制属性吗?

As @Confused kindly pointed out, the docs show it is possible to set velocity directly: https://developer.apple.com/reference/scenekit/scnphysicsbody/1514757-velocity正如@Confused 亲切指出的那样,文档显示可以直接设置velocityhttps : //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).关键是使用动态体型,而不是运动体型(显然也不是静态体型)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM