SceneKit中的allowRotation? [英] allowRotation in SceneKit?
问题描述
如何禁止在SceneKit中旋转节点?
How can I disallow rotation of a node in SceneKit?
例如,我希望模型(圆锥体)能够动态,跳跃和飞行,但总是如此垂直导向?
For ex., I want a model (cone) to be dynamic, jumping and flying, but always vertically oriented?
我尝试修复它就像苹果的车辆演示一样,这是一个糟糕的解决方案。我也尝试下面的代码,但模型只是缓慢而且小故障掉落
I tried fix it like in apple's vehicle demo, it is bad solution. Also I tried below code, but model just slowly and glitchy falls down
- (void)renderer:(id<SCNSceneRenderer>)aRenderer didSimulatePhysicsAtTime:(NSTimeInterval)time{
_node.rotation = SCNVector4Make(0, 0, 0, 0);
//[_node.physicsBody resetTransform]; // - tried this too
}
...最后我没找到任何在scenekit手册中allowRotation = NO。
...and finally I did not find any "allowRotation=NO" in scenekit manuals.
推荐答案
而不是布尔 allowsRotation
在SpriteKit中标记,SceneKit允许您选择允许身体旋转的方向和数量。请参阅 angularVelocityFactor
属性。
Instead of a Boolean allowsRotation
flag like in SpriteKit, SceneKit lets you choose which directions a body is allowed to rotate in and by how much. See the angularVelocityFactor
property.
这可能比在不同值之间切换质量更好 - 这种方法看起来可能是非预期的行为,所以你可能不想依赖它。
This is probably a better idea than toggling the mass between different values — that approach looks like it could be unintended behavior, so you might not want to rely on it.
这篇关于SceneKit中的allowRotation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!