Unity 物体旋转

 void RotateCamera()
    {
        float h = Input.GetAxis("Mouse X");
        //Debug.Log(h + "______________");

        transform.RotateAround(transform.position, Vector3.up, h * RotateSpeed * 4);
       

        float V = Input.GetAxis("Mouse Y");
        //Debug.Log(V + "______________");

        V = Mathf.Clamp(V, -4, 4);

        float x = transform.localEulerAngles.x;
       

        if ((V > 0 && ((x < 90 || x > 300))) || (V < 0 && (x < 60 || x > 270)))
        {
            transform.RotateAround(transform.position, transform.right, -V * RotateSpeed * 4);

        }
    }

  

posted @ 2020-09-29 16:55  D个人笔记  阅读(110)  评论(0编辑  收藏  举报