PhysicsBody 在平移和旋转后保持不变

PhysicsBody stays after translation and rotation

我有一个附有立方体的节点,例如代表一扇门。 physicsbody 类型是.static。如果我向上动画节点,旋转它并将它向下动画到 physicsbody 的原始位置保持在上部位置。 在调试模式下,physicsbody 的颜色首先是灰色(我假设 gray = .static),向上平移后,physicsbody 停留在底部。一旦我将节点旋转到上部位置,物理体就会变成绿色并向上移动到节点位置。在我将节点向下平移到原始位置后,physicsbody 停留在上部位置。为什么会出现这种行为?这是因为类型是 .static 吗?

我知道如果我将 physicsbody 类型设置为 .kinematic(在调试中显示为红色)模式,它会按预期工作。 physicsbody 适应平移和旋转。但是对于 .static 类型,我可以在 fps 下降之前放置比 .dynamic 类型更多的对象。

the documentation for SCNPhysicsBodyTypeStatic得知是

A physics body that is unaffected by forces or collisions and cannot move

但是你可以使用resetTransform明确告诉引擎节点已经移动并且物理体需要更新:

If you change the position or orientation of a node with an attached static or dynamic physics body, call this method afterward to ensure that the physics simulation incorporates the change. You need not call this method for kinematic bodies.

Note that dynamic and physics bodies are designed to be moved only by the physics simulation or not at all. You may use this method to move them regardless of this restriction, but at a cost to performance.