How to get rid of all the 0 in the console

If you are like me and want to get rid of all of the 0 popping up in the console, here is a simple solution without too much additional knowledge:

void Update()
    {
        
        horizontalMovement();
        verticalMovement();
        
    }
    void horizontalMovement()
    {
        float horizontalThrow = Input.GetAxis("Horizontal");
        if (horizontalThrow < Mathf.Epsilon && horizontalThrow > -Mathf.Epsilon) { return; }
        {
            Debug.Log(horizontalThrow);
        }
    }
    void verticalMovement()
    {
        float verticalThrow = Input.GetAxis("Vertical");
        if (verticalThrow < Mathf.Epsilon && verticalThrow > -Mathf.Epsilon) { return; }
        {
            Debug.Log(verticalThrow);
        }
    }

The only new thing here is the && (AND) operator to basically say:
Exclude everything between -0 and 0. (since Mathf.Epsilon is something like 0.0000000…1, the +/- matter).

Please correct me, if this is bad practice and if there is an easier solution.

Edit:

The other way around seems more plausible, so we can dump the { return; }

void Update()
    {
        
        horizontalMovement();
        verticalMovement();
        
    }
    void horizontalMovement()
    {
        float horizontalThrow = Input.GetAxis("Horizontal");
        if (horizontalThrow > Mathf.Epsilon || horizontalThrow < -Mathf.Epsilon)
        {
            Debug.Log(horizontalThrow);
        }
    }
    void verticalMovement()
    {
        float verticalThrow = Input.GetAxis("Vertical");
        if (verticalThrow > Mathf.Epsilon || verticalThrow < -Mathf.Epsilon)
        {
            Debug.Log(verticalThrow);
        }
    }

Privacy & Terms