缩放SCNNode时更新SCNPhysicsBody [英] Update SCNPhysicsBody when scaling SCNNode

查看:126
本文介绍了缩放SCNNode时更新SCNPhysicsBody的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道SCNPhysicsBody在节点缩放时不会缩放,但是我没有找到解决此问题的好方法.我要缩放节点,然后在缩放它之后将SCNPhysicsBody更新到该节点.

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?

推荐答案

尝试一下

let nodeScale = SCNVector3(0.5,0.5,0.5)

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

这篇关于缩放SCNNode时更新SCNPhysicsBody的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆