Raycast and Compare Tag are not working

It should work, gameObject with the tag exist :confused:

RaycastHit2D _hitInfo = Physics2D.Raycast(transform.position, transform.right, distance);

Debug.DrawLine(transform.position, transform.position + transform.right * distance, Color.green);

            if (_hitInfo.collider.CompareTag("Obstacle")){
                Debug.Log("Hit");
                faceDirection *= -1;
            }

Instead I get: Object reference not set to an instance of an object
…which doesnt make much sense…
Same with:
_hitInfo.collider.tag == “Obstacle”

If the ray didn’t hit anything collider will be set to null.