private void Update()
        {
            VirtualInputManager.Instance.exit = Input.GetKeyDown(KeyCode.Escape);

            Vector2 cursorNormalized = cameraGrip.getCameraHeld().ScreenToViewportPoint(Input.mousePosition);

            VirtualInputManager.Instance.cursorX = cursorNormalized.x - 0.5f;
            VirtualInputManager.Instance.cursorY = cursorNormalized.y - 0.5f;

            if (Input.GetMouseButton(0))
            {
                Cursor.lockState = CursorLockMode.Confined;
                VirtualInputManager.Instance.button1 = true;
            }
            else
            {
                VirtualInputManager.Instance.button1 = false;
            };
            VirtualInputManager.Instance.button2 = Input.GetMouseButtonDown(1);

            VirtualInputManager.Instance.holdBack = Input.GetKey(KeyCode.LeftShift);
            VirtualInputManager.Instance.left     = Input.GetKey(KeyCode.A);
            VirtualInputManager.Instance.right    = Input.GetKey(KeyCode.D);
            VirtualInputManager.Instance.up       = Input.GetKey(KeyCode.W);
            VirtualInputManager.Instance.down     = Input.GetKey(KeyCode.S);
        }
Exemplo n.º 2
0
        Vector3 fitCursorToScreen(Vector3 pos)
        {
            Camera cameraCur       = cameraGrip.getCameraHeld();
            float  cameraMaxRadius = cameraCur.GetComponent <CameraScript>().cameraMaxRadius;

            Vector3 cameraFrame;

            cameraFrame.y = cameraCur.orthographicSize * 2;
            cameraFrame.x = cameraCur.aspect * cameraFrame.y;
            //float playerCursorAngle = Vector3.Dot(Vector3.Normalize(this.transform.position - player.transform.position), Vector3.up) ;
            //Debug.Log(Mathf.Pow(Mathf.Cos(2*playerCursorAngle), 2));
            //Try using magnitudes in the corners and a full two radiuses in the edge middles
            cameraFrame.x += cameraMaxRadius * 2; // (1+(Mathf.Pow(Mathf.Cos(playerCursorAngle*2), 2)));
            cameraFrame.y += cameraMaxRadius * 2; // (1+(Mathf.Pow(Mathf.Cos(playerCursorAngle*2), 2)));

            pos.x *= cameraFrame.x;
            pos.y *= cameraFrame.y;

            return(pos);
        }