缩放 SCNNode 时更新 SCNPhysicsBody

编程入门 行业动态 更新时间:2024-10-27 22:18:58
本文介绍了缩放 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

本文发布于:2023-06-04 21:18:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/505245.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缩放   SCNNode   SCNPhysicsBody

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!