angular色不在场景包中的所需场景中移动

我想移动我的angular色在场景工具包。我有一个地图,因为github Fpscontroller,我希望我的angular色在这个地图移动,但是当我触摸移动angular色跳跃,不知道去哪里是我的代码。 `

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { for touch in touches { if CGRectContainsPoint(gameView.virtualDPadBounds(), touch.locationInView(gameView)) { if padTouch == nil { padTouch = touch controllerStoredDirection = float2(0.0) } } else if panningTouch == nil { panningTouch = touches.first } if padTouch != nil && panningTouch != nil { break } } } override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) { if let touch = panningTouch { let displacement = (float2(touch.locationInView(view)) - float2(touch.previousLocationInView(view))) panCamera(displacement) } if let touch = padTouch { let displacement = (float2(touch.locationInView(view)) - float2(touch.previousLocationInView(view))) controllerStoredDirection = clamp(mix(controllerStoredDirection, displacement, t: ViewController.controllerAcceleration), min: -ViewController.controllerDirectionLimit, max: ViewController.controllerDirectionLimit) } } func commonTouchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { if let touch = panningTouch { if touches.contains(touch) { panningTouch = nil } } if let touch = padTouch { if touches.contains(touch) || event?.touchesForView(view)?.contains(touch) == false { padTouch = nil controllerStoredDirection = float2(0.0) } } } override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) { commonTouchesEnded(touches!, withEvent: event) } override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { commonTouchesEnded(touches, withEvent: event) } 

我跟着苹果狐狸的例子,用触摸和我的视图控制器移动

 func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool { return true } func walkGestureRecognized(gesture: UIPanGestureRecognizer) { if gesture.state == UIGestureRecognizerState.Ended || gesture.state == UIGestureRecognizerState.Cancelled { gesture.setTranslation(CGPointZero, inView: self.view) } } func renderer(aRenderer: SCNSceneRenderer, updateAtTime time: NSTimeInterval) { //get walk gesture translation let translation = walkGesture.translationInView(self.view) //create impulse vector for hero let angle = heroNode.presentationNode.rotation.w * heroNode.presentationNode.rotation.y var impulse = SCNVector3(x: max(-1, min(1, Float(translation.x) / 50)), y: 0, z: max(-1, min(1, Float(-translation.y) / 50))) impulse = SCNVector3( x: impulse.x * cos(angle) - impulse.z * sin(angle), y: 0, z: impulse.x * -sin(angle) - impulse.z * cos(angle) ) heroNode.physicsBody?.applyForce(impulse, impulse: true) let scene = gameView.scene! let direction = characterDirection() let groundNode = character.walkInDirection(direction, time: time, scene: scene, groundTypeFromMaterial:groundTypeFromMaterial) 

设置字符的位置和方向….

  private func characterDirection() -> float3 { let controllerDirection = self.controllerDirection() var direction = float3(controllerDirection.x, 0.0, controllerDirection.y) if let pov = gameView.pointOfView { let p1 = pov.presentationNode.convertPosition(SCNVector3(direction), toNode: nil) let p0 = pov.presentationNode.convertPosition(SCNVector3Zero, toNode: nil) direction = float3(Float(p1.x - p0.x), 0.0, Float(p1.z - p0.z)) if direction.x != 0.0 || direction.z != 0.0 { direction = normalize(direction) } } return direction } 

实际上在视图控制器类中有两个场景调用,一个是mapNode调用的空场景,另一个是sceneNode

 let scene = SCNScene() scene.rootNode.addChildNode(heroNode) let personScene = SCNScene(named: "game.scnassets/person.scn")! personNode = personScene.rootNode.childNodeWithName("person", recursively: true) personNode?.position = SCNVector3(x:4.5,y:0,z:25) node.addChildNode(personNode) scene.rootNode.addChildNode(character.node) 

我正在更新我的问题,一些更多的细节,你可以看到在这个屏幕截图图像im attatching在这里enter image description here我想移动这个狐狸在地图上触摸,但它不工作,只是跳转,从地图出去,当我摸….. plz有人告诉我在代码中我的错在哪里