unity 鼠标控制摄像机围绕物体旋转

来源:互联网 发布:广发基金工资很高知乎 编辑:程序博客网 时间:2024/04/27 23:28
  void LateUpdate() //对摄像机的操作写在LateUpdate里  {           x += Input.GetAxis("Mouse X") * rotateSpeed * Time.deltaTime;           y -= Input.GetAxis("Mouse Y") * rotateSpeed * Time.deltaTime;            //根据人物位置确定摄像机的位置,这里用四元数进行了旋转            Quaternion camPosRotation = Quaternion.Euler(y, x, 0);            mTrans.position = camPosRotation * distanceVec + player.position;            mTrans.LookAt(player.position);  }
1 0
原创粉丝点击