gpt4 book ai didi

ios - SCNAction 后节点失去重力

转载 作者:行者123 更新时间:2023-11-28 20:50:48 26 4
gpt4 key购买 nike

我想放下一个物体,然后将它移回顶部,让它再次落下。第一部分工作正常,但随后节点似乎失去了重力并且不再下落。看起来它的物理 body 停留在地板上并且没有被 SCNActions 移动。解决方案是什么?谢谢

    let shape = SCNPhysicsShape(geometry: SCNBox(width: boxSize, height: 0.001, length: boxSize, chamferRadius: 0), options:nil)
node.physicsBody = SCNPhysicsBody(type: .dynamic, shape: shape)
...
SCNTransaction.begin()
SCNTransaction.animationDuration = 5
let actions = SCNAction.sequence([
SCNAction.move(to: SCNVector3(x: 0, y: 3, z: -2), duration: 1),
SCNAction.rotate(by: .pi*2, around: SCNVector3(0,1,0), duration: 1)
])
node.runAction(actions)
//node.presentation.runAction(actions) //also not working
SCNTransaction.commit()

最佳答案

您必须通过调用-resetTransform 让物理模拟知道物理体已经移动。 .

关于ios - SCNAction 后节点失去重力,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58630767/

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