Exemplo n.º 1
0
        private void UpdateCamera()
        {
            var leftEye  = currentTarget.head.Rend_eye_L.transform.position;
            var rightEye = currentTarget.head.Rend_eye_R.transform.position;

            Camera.main.transform.position = Vector3.Lerp(leftEye, rightEye, 0.5f);
            var offset = currentTarget.sex == Character.SEX.MALE ? MaleOffset : FemaleOffset;

            Camera.main.transform.Translate(offset);
            Camera.main.transform.rotation = currentTarget.head.Rend_eye_L.transform.rotation;
            Camera.main.fieldOfView        = RealPOVCore.DefaultFOV.Value;

            if (!OnUI && (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2)))
            {
                dragging = true;
            }
            else if (!Input.GetMouseButton(0) && !Input.GetMouseButton(1) && !Input.GetMouseButton(2))
            {
                dragging = false;
            }

            if (dragging)
            {
                if (ConfigData.dragLock)
                {
                    GameCursor.Lock();
                }

                float x = Input.GetAxis("Mouse X") * RealPOVCore.MouseSens.Value;
                float y = Input.GetAxis("Mouse Y") * RealPOVCore.MouseSens.Value;

                if (Input.GetMouseButton(0))
                {
                    rotation += new Vector3(-y, x, 0f);
                }
                else if (Input.GetMouseButton(1))
                {
                    if (Input.GetKey(KeyCode.LeftShift))
                    {
                        rotation += new Vector3(0f, 0f, -x);
                    }
                    else
                    {
                        Camera.main.fieldOfView     += x;
                        RealPOVCore.DefaultFOV.Value = Camera.main.fieldOfView;
                    }
                }
            }
        }