Example #1
0
    void Move()
    {
        if (axisToMove == Axis.x)
        {
            inputForce = Input.GetAxis("Horizontal"); // Cache the horizontal input.
        }
        if (axisToMove == Axis.y)
        {
            inputForce = Input.GetAxis("Vertical"); // Cache the vertical input.
        }

        //If not analogic
        if (!analogicInput)
        {
            if (inputForce > 0.1f)
            {
                inputForce = 1;
            }
            else if (inputForce < -0.1f)
            {
                inputForce = -1;
            }
            else
            {
                inputForce = 0;
            }
        }

        if (Input.touchCount > 0)
        {
            inputForce = touchDirection;
        }

        if (transform.position.x > limit)
        {
            inputForce++;
            limit += 500;
        }

        rigidBody2DUnidirectional.Move(inputForce);
    }