Ejemplo n.º 1
0
    private void InputUpdate()
    {
        m_horisontal = m_inputHandler.Input_LHorizontal();
        m_vertical   = m_inputHandler.Input_LVertical();
        m_moveDir    = new Vector2(m_horisontal, m_vertical);
        m_moveDir.Normalize();
        m_moveAmount = Mathf.Clamp01(Mathf.Abs(m_horisontal) + Mathf.Abs(m_vertical));

        bool isInput = false;

        // カーソルを動かした時
        if (m_cursorController.GetIsCursorCheck())
        {
            m_armDir = m_cursorController.transform.position - transform.position;
            isInput  = true;
        }

        Vector2 armDir;

        armDir.x = m_inputHandler.Input_RHorizontal();
        armDir.y = m_inputHandler.Input_RVertical();

        // 右スティックを動かした時
        if (armDir.magnitude > 0.0f)
        {
            m_armDir = armDir;
            isInput  = true;
        }

        m_armDir.Normalize();
        bool isFrip = (Vector2.Dot(transform.right, m_armDir) >= 0) ? false : true;

        SpriteFlip(isFrip);
        Quaternion to_q = Quaternion.FromToRotation(m_magnetArmTransform.right, (isFrip) ? -m_armDir : m_armDir);

        m_magnetArmTransform.rotation = to_q * m_magnetArmTransform.rotation;
        Vector3 angle = m_magnetArmTransform.localEulerAngles;

        angle.x = angle.y = 0.0f;
        m_magnetArmTransform.localEulerAngles = angle;
    }