2015-05-12 16 views
1

如何讓我的節點始終朝着它所面對的方向走?SceneKit Steering

float tilt = _motionManager.accelerometerData.acceleration.x; 
[_player runAction:[SCNAction rotateByX:0 y:-tilt * 0.03 z:0 duration:_dt]]; 
//Make SCNAction to moveBy X and Z in the direction _player is facing. 

有沒有辦法找出SCNVector3是在_player所面臨的方向上離1點的距離?

回答

1

獲取播放器前方的位置。

SCNVector3 pos = [_scene.rootNode convertPosition:SCNVector3Make(0, 0, -1) fromNode:_player];