gpt4 book ai didi

swift - 缩放 SCNNode 时更新 SCNPhysicsBody

转载 作者:搜寻专家 更新时间:2023-11-01 06:14:25 26 4
gpt4 key购买 nike

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

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)

enter image description here

有没有人想出解决这个问题的好方法?

最佳答案

试试这个

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com