SCNAction后节点失去重力

时间:2019-10-30 17:26:14

标签: ios scenekit scnnode

我想放下一个物体,然后将其移回顶部,然后使其再次下降。第一部分工作,但随后该节点似乎失去了引力,并且不再下降。看起来它的物理身体停留在地板上,并且不受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()

1 个答案:

答案 0 :(得分:2)

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