Group Group Group Group Group Group Group Group Group

6DOF with coremation, Scenekit and Swift

#1

I am developing a game with 6DOF (degrees of freedom), just like the game Everspace with use of the coremotion in SceneKit with Swift. Here is a part of the code, but it works not correct.

func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {

cameraNode.eulerAngles = SCNVector3Make(Float(rot.roll + M_PI/2) * 2, -Float(rot.yaw) * 3, -Float(rot.pitch * 5))

let z = cos(rot.pitch)*sin(rot.yaw)
let y = sin(rot.pitch)
let x = cos(rot.pitch)*cos(rot.yaw)

let view = SCNVector3(x: Float(x), y : Float(y), z : Float(z))

cameraNode.position = cameraNode.position + (view * 0.1)
//cameraNode.physicsBody?.velocity = -view
}

The problem is the camera don’ t move with “cameraNode.physicsBody?.velocity = -view”, so I test if it moves with “cameraNode.position = cameraNode.position + (view * 0.1)”. With this the camera moves, but not in the correct direction. Is there someone who knows how to solve this?

#2

@chrislanguage Can you please help with this when you get a chance? Thank you - much appreciated! :]

#3

Yes, I hope Chris can help with this!!!

#4

Is there anybody knowing how to solve this?

closed #5

This topic was automatically closed after 166 days. New replies are no longer allowed.