Scenekit PhysicEngine follow rolling ball

∥☆過路亽.° 提交于 2019-12-05 18:44:33

It's pretty simple. You just need to change the camera node's position at each frame to the ball's presentationNode plus an offset to avoid being inside of it.

I'm not too familiar with Swift but the code would look something like this:

func renderer(aRenderer: SCNSceneRenderer, didSimulatePhysicsAtTime time: NSTimeInterval){
    var ballP = ballNode.presentationNode.position
    // Offset the camera up and on X:
    var cameraP = SCNVector3(x: ballP.x+5, y: ballP.y+10, z: ballP.z)
    cameraNode.position = cameraP       
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!