我知道scnpphysisbody在节点缩放时不会缩放,但我还没有找到解决此问题的好方法。我想缩放节点,然后在缩放后将scnpphysisbody更新为node。

let box = SCNBox(width: 0.2, height: 0.3, length: 0.4, chamferRadius: 0.1)
box.firstMaterial?.diffuse.contents = UIColor.blue
var boxNode = SCNNode(geometry: box)
boxNode.scale = SCNVector3(0.5, 0.5, 0.5)
boxNode.position.x += 0.5

boxNode.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.static, shape: SCNPhysicsShape(geometry: box, options: nil))

sceneView.scene.rootNode.addChildNode(boxNode)

swift - 缩放SCNNode时更新SCNPhysicsBody-LMLPHP
有人想出解决这个问题的好办法吗?

最佳答案

试试这个

let nodeScale = SCNVector3(0.5,0.5,0.5)

 boxNode.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.static, shape: SCNPhysicsShape(geometry: box, options:  [SCNPhysicsShape.Option.scale: nodeScale]))

关于swift - 缩放SCNNode时更新SCNPhysicsBody,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48153416/

10-09 18:05