问题
I know that SCNPhysicsBody dont scale when the node scale, but I haven't found a great solution to fix this. I want to scale the node and then update the SCNPhysicsBody to node after scaling it.
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)
Has anyone come up with a great solution to this problem?
回答1:
Try this
let nodeScale = SCNVector3(0.5,0.5,0.5)
boxNode.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.static, shape: SCNPhysicsShape(geometry: box, options: [SCNPhysicsShape.Option.scale: nodeScale]))
来源:https://stackoverflow.com/questions/48153416/update-scnphysicsbody-when-scaling-scnnode