2014-12-06 55 views
0

我在將相機移動到汽車後方時遇到了問題。相機無法自行調整,直接位於汽車的新方向後面。如何將相機調整到模型的新方向後面?

我的代碼:

Vector3 tmpV = new Vector3(); 
    Quaternion quatRotation = new Quaternion(); 
    //chassis is car 
    chassis.transform.getTranslation(camera.position); 
    tmpV.set(camera.position).sub(5, 0, 5).y = 0f; 
    chassis.transform.getRotation(quatRotation); 
    camera.rotate(quatRotation); 
    camera.position.add(tmpV.nor().scl(-4f)).y = 4.f; 
    chassis.transform.getTranslation(tmpV); 
    camera.lookAt(tmpV); 
    camera.up.set(Vector3.Y); 

向右移動時,它是目前發生的事情:

什麼,我需要向右移動時發生:

+0

https://github.com/xoppa/world/blob/master/src/com/xoppa/android/world/ChaseCamera.java在此處查看它的操作:https://www.youtube.com/看?v = alCLHywqtiI – Xoppa 2014-12-06 17:58:16

+0

@Xoppa謝謝 – user886550 2014-12-07 18:33:13

回答

0

通過使用這個類的從這個link Xoppa發表評論:

camera.desiredLocation.set(new Vector3(0, 5, 5)); 
    camera.transform=chassis.transform; 
    camera.up.set(Vector3.Y); 
相關問題