Ejemplo n.º 1
0
    private void Update()
    {
        if (!m_matorCharacter)
        {
            return;
        }

        m_matorCharacter.SetFloat
        (
            "Speed",
            C_SimpleMath.GetSpeed(ref m_fControllerHorizontal, ref m_fControllerVertical)
        );

        if (PlayerCollider.GetInstance() && PlayerCollider.GetInstance().IsFalling())
        {
            transform.position += new Vector3(0.0f, -m_fFallingSpeed, 0.0f);

            return;
        }

        if (m_fControllerHorizontal != 0.0f && m_fControllerVertical != 0.0f)
        {
            Vector3 vecLook = new Vector3(m_fControllerHorizontal, 0.0f, m_fControllerVertical);

            transform.rotation = Quaternion.LookRotation(vecLook);
        }
    }
Ejemplo n.º 2
0
    private void HandleInput(Vector3 vecInput)
    {
        Vector3 vecDiff     = Vector3.zero;
        Vector2 vecNormDiff = Vector2.zero;

        if (m_isButtonPressed)
        {
            vecDiff = vecInput - m_vecStartPosition;

            if (vecDiff.sqrMagnitude > C_SimpleMath.Square(m_fDragRadius))
            {
                vecDiff.Normalize();

                m_transTouchPad.position  = vecDiff * m_fDragRadius;
                m_transTouchPad.position += m_vecStartPosition;
            }
            else
            {
                m_transTouchPad.position = vecInput;
            }
        }
        else
        {
            m_transTouchPad.position = m_vecStartPosition;
        }

        vecDiff     = m_transTouchPad.position - m_vecStartPosition;
        vecNormDiff = new Vector3(vecDiff.x / m_fDragRadius, vecDiff.y / m_fDragRadius);

        if (m_movement)
        {
            m_movement.OnStickChanged(vecNormDiff);
        }
    }