Ejemplo n.º 1
0
        public float HorizontalDirection()
        {
            if (leftButton.GetButtonDown(userId))
            {
                movingLeft  = true;
                movingRight = false;
            }
            else if (leftButton.GetButtonUp(userId))
            {
                movingLeft  = false;
                movingRight = false;
            }
            else if (rightButton.GetButtonDown(userId))
            {
                movingLeft  = false;
                movingRight = true;
            }
            else if (rightButton.GetButtonUp(userId))
            {
                movingLeft  = false;
                movingRight = false;
            }

            if (movingLeft)
            {
                return(-1);
            }

            if (movingRight)
            {
                return(1);
            }

            return(0);
        }
Ejemplo n.º 2
0
        public float VerticalDirection()
        {
            if (forwardButton.GetButtonDown(userId))
            {
                movingForward  = true;
                movingBackward = false;
            }
            else if (forwardButton.GetButtonUp(userId))
            {
                movingForward  = false;
                movingBackward = false;
            }
            else if (backButton.GetButtonDown(userId))
            {
                movingForward  = false;
                movingBackward = true;
            }
            else if (backButton.GetButtonUp(userId))
            {
                movingForward  = false;
                movingBackward = false;
            }

            if (movingForward)
            {
                return(1);
            }

            if (movingBackward)
            {
                return(-1);
            }

            return(0);
        }