我有一个节点(nodeCollection),它具有一个SCNNode作为childNode,其创建方式如下:

let boxGeo = SCNBox(width: 1, height: 1, length: 1, chamferRadius: 0.0)
let node = SCNNode(geometry: boxGeo)
node.physicsBody = SCNPhysicsBody.staticBody()


我也像这样创建redbox节点:

let redBox = SCNNode()
redBox.geometry = SCNBox(width: 0.5, height: 0.5, length: 0.5, chamferRadius: 0.1)
redBox.geometry?.firstMaterial?.diffuse.contents = UIColor.redColor()
redBox.position = SCNVector3Make(0, 1, -2)
redBox.physicsBody = SCNPhysicsBody.dynamicBody()


然后,我运行以下代码以使节点旋转

let rotateAction = SCNAction.rotateByAngle(CGFloat(M_PI_2), aroundAxis: SCNVector3Make(0, 0, 1), duration: 0.15)
rotateAction.timingMode = .EaseInEaseOut
nodeCollection.runAction(rotateAction)


然后,我将nodeCollection和redBox都作为childNodes添加到SCNScene

但是正如您看到的那样,当我在nodeCollection上执行旋转时,redBox的物理原理不成立。当红色框停在蓝框上并停在其上时,物理原理起作用

我该如何解决这个问题,以便当蓝色框旋转时,它不仅会夹住redBox

ios - SCNAction.rotate剪辑通过其他节点-LMLPHP

最佳答案

尝试将蓝色框的physicsBody类型更改为kinematic,静态物体不应移动。

此处说明了不同的类型:
https://developer.apple.com/library/ios/documentation/SceneKit/Reference/SCNPhysicsBody_Class/#//apple_ref/c/tdef/SCNPhysicsBodyType

10-08 02:34