SceneKit will not scale the dynamic body

I have a sphere that is a dynamic body. I would like to revive the scope of this sphere so that it grows in size:

let sphere = SCNNode(geometry: SCNSphere(radius: 1))
scene.rootNode.addChildNode(sphere)
sphere.physicsBody = SCNPhysicsBody.dynamicBody()
sphere.runAction(SCNAction.scaleTo(10, duration: 1))

However, this does not work. The sphere falls due to gravity, but remains the same size. If I comment on the line that gives the sphere a physical body, the zoom animation will look as it should.

This strange phenomenon is observed even without animation. A simple zooming in on a sphere does not directly work:

let sphere = SCNNode(geometry: SCNSphere(radius: 1))
scene.rootNode.addChildNode(sphere)
sphere.physicsBody = SCNPhysicsBody.dynamicBody()
sphere.scale = SCNVector3(x: 10, y: 10, z: 10)

The sphere falls, but remains with a radius of 1. If the ball does not scale before the physical body is added. In this case, the sphere begins to scale to 10 and falls down, while maintaining its radius of 10.

, , , , , , , :

let sphere = SCNNode(geometry: SCNSphere(radius: 1))
scene.rootNode.addChildNode(sphere)
sphere.physicsBody = SCNPhysicsBody.dynamicBody()
sphere.runAction(SCNAction.scaleTo(10, duration: 1), completionHandler: {() in
    println(sphere.scale.x)
    sphere.physicsBody = nil
})

? ( , .) - ?

+4
3

" ", , , " ". , ? , , , , ?

, "w40 > -Man" - . , , , -, .:)

, , , , . :

let duration = 5.0
node.runAction(.customActionWithDuration(duration, actionBlock: { node, progress in
    let scale = 1.0 + progress / CGFloat(duration)
    node.physicsBody = nil
    node.scale = SCNVector3(x: scale, y: scale, z: scale)
    node.physicsBody = .dynamicBody()
}))

, - - progress , . ( , , , , .)

SCNPhysicsField. , , , , .

+6

, .scn . , , , , . , .

0

- / . node node.

sceneKit, on the other hand, applies the physics simulation result to presentationNode, which represents the current rendering state of the node. You can check the information presentationNodeto confirm why your animation sucks.

0
source

Source: https://habr.com/ru/post/1570801/


All Articles