I'm using ball as the main physics body of my player:
setup_Player () {
playerGeometry = SCNSphere(radius: CGFloat(radius))
playerGeometry.segmentCount = 64
player = SCNNode(geometry: playerGeometry)
player.geometry?.materials = [playerMaterial];
player.position = SCNVector3(x: 1, y: 15, z: 0.5)
let playerShape = SCNPhysicsShape(geometry: playerGeometry, options: nil)
let playerBody = SCNPhysicsBody(type: .dynamic, shape: playerShape)
player.physicsBody?.categoryBitMask = collisionRollingBall
player.physicsBody?.collisionBitMask = collsionTarget
player.physicsBody?.mass = 10
player.physicsBody = playerBody
scene.rootNode.addChildNode(player)
}
Wrote code to fix position of camera next to my player:
func setupCamera () {
//create a main camera
cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
cameraNode.camera?.zFar = 100;
cameraNode.position = SCNVector3Make(0, 0, 0)
cameraNode.eulerAngles = SCNVector3Make(0, 0, 0)
cameraNode.rotation = SCNVector4Make(0, 1, 0, Float(-M_PI_4*0.75))
scene.rootNode.addChildNode(cameraNode)
//add a secondary camera to the player
let frontCameraNode = SCNNode()
frontCameraNode.position = SCNVector3Make(0, 15, 0)
frontCameraNode.rotation = SCNVector4Make(1, 0, 0, Float(-M_PI_4*2.2))
frontCameraNode.camera = SCNCamera()
frontCameraNode.camera?.zFar = 100
player.addChildNode(frontCameraNode)
}
I just need to freeze the camera position at a certain distance, as in the games from 3rd person.
In such a scenario, the camera acquires the physical properties of the ball and rotating with it. But i need to follow player and all, not rotating with huge speed of ball...
How to fix the camera next to the player, not inheriting its properties? Any ideas how ignore rotation of physic body ?
Thanks in advance.