SCNAction 后节点失去重力
Node losing gravity after SCNAction
我想放下一个 object 然后将它移回顶部并让它再次落下。第一部分工作正常,但随后节点似乎失去了重力并且不再下落。看起来它的物理 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
让物理模拟知道物理体已经移动。
我想放下一个 object 然后将它移回顶部并让它再次落下。第一部分工作正常,但随后节点似乎失去了重力并且不再下落。看起来它的物理 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
让物理模拟知道物理体已经移动。