0

I have a node (nodeCollection) that has an SCNNode as a childNode which is created like this:

let boxGeo = SCNBox(width: 1, height: 1, length: 1, chamferRadius: 0.0)
let node = SCNNode(geometry: boxGeo)
node.physicsBody = SCNPhysicsBody.staticBody()

I am also creating the redbox node like so:

let redBox = SCNNode()
redBox.geometry = SCNBox(width: 0.5, height: 0.5, length: 0.5, chamferRadius: 0.1)
redBox.geometry?.firstMaterial?.diffuse.contents = UIColor.redColor()
redBox.position = SCNVector3Make(0, 1, -2)
redBox.physicsBody = SCNPhysicsBody.dynamicBody()

I am then running the below code to make the nodes rotate

let rotateAction = SCNAction.rotateByAngle(CGFloat(M_PI_2), aroundAxis: SCNVector3Make(0, 0, 1), duration: 0.15)
rotateAction.timingMode = .EaseInEaseOut
nodeCollection.runAction(rotateAction)

I then add both the nodeCollection and redBox as childNodes to the SCNScene

But as you can see when I perform the rotate on the nodeCollection the physics of the redBox doesn't hold. The physics works when the red box drops onto the scene as it stops and rests on the bluebox

How can I fix this so that when the blue box rotates, it doesn't just clip through the redBox

enter image description here

user3916570
  • 780
  • 1
  • 9
  • 23

1 Answers1

2

Try changing the physicsBody type of the blue box to kinematic, static bodies are not supposed to move.

The different types are explained here: https://developer.apple.com/library/ios/documentation/SceneKit/Reference/SCNPhysicsBody_Class/#//apple_ref/c/tdef/SCNPhysicsBodyType

James P
  • 4,786
  • 2
  • 35
  • 52