如何旋转相机以单击鼠标

How rotate camera to Mouse click

我制作模型查看器(使用 Unity3d)。现在我与模型进行鼠标交互。如何将相机旋转到鼠标点击位置。 http://prntscr.com/990q9y

也许是这样的?

你想要"click",对吧? 哦,你想换摄像头。

if (Input.GetMouseButtonDown(0))
         {
             RaycastHit hit;
             Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                 if (Physics.Raycast(ray, out hit))
                 {
                   Camera.main.transform.localEulerAngles=hit.point;
                 } 
         }

//or try to fix the z thing:
if (Input.GetMouseButtonDown(0))
             {
                 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                 Camera.main.transform.localEulerAngles = ray.origin + (ray.direction * 4.5f);
             }

我在这里看到这个:http://answers.unity3d.com/questions/376735/get-world-coordinates-from-mouse-click.html

也许这对您有很大帮助:

此代码有效,但旋转的流畅度如何?

if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
var pos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
{
transform.transform.LookAt(hit.point);
player.UpdatePosition();
}
}