0
如何根據移動球體的x位置移動攝像機,但同時忽略該球體的y和z座標?這裏是我的下面就其3名維球體代碼:SceneKit相機僅在x軸上跟隨物體? - Swift
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
cameraNode.camera?.usesOrthographicProjection = true
cameraNode.camera?.orthographicScale = 2
let constraint = SCNLookAtConstraint(target: sphere)
constraint.gimbalLockEnabled = true
self.cameraNode.constraints = [constraint]
cameraNode.position = SCNVector3Make(20, 20, 20)
cameraNode.eulerAngles = SCNVector3Make(0, 45, 0)
sphere.addChildNode(cameraNode)
如何我只是按照剛剛球體的x位置,而不是它的y和z位置呢?
您無法訪問'cameraNode.position.x'並直接賦值嗎? – codetiger