コード例 #1
0
    void InputManager()
    {
        if (isThrown == false)
        {
            if (Input.GetMouseButtonDown(0))
            {
                bagTempPos         = bag.transform.position;
                bagRB.gravityScale = 0;
                aimingArrow.SetActive(true);
                hasTakenPosInput = true;
            }
            if (Input.GetMouseButton(0) && hasTakenPosInput == true)
            {
                bag.transform.position = bagTempPos;
                Vector3 mousePos = Input.mousePosition;
                mousePos.z = 5.23f;

                Vector3 objectPos = Camera.main.WorldToScreenPoint(transform.position);
                mousePos.x = mousePos.x - objectPos.x;
                mousePos.y = mousePos.y - objectPos.y;
                float angle = Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg;
                transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
                BS = BagState.flying;
            }
            if (Input.GetMouseButtonUp(0) && hasTakenPosInput == true)
            {
                ThrowBag();
                aimingArrow.SetActive(false);
                bagRB.gravityScale = 1;
                isThrown           = true;
                ISG.PlayBagShootSound();
                CS.SetCameraOrtographicSize(8.0f);
                CS.SetCameraRestriction(false, true);
                hasTakenPosInput = false;
            }
        }
    }