Tag doesn't work when gameObject is a child of the Main camera?

I have a gameobject with the tag ‘right’, and when this gameobject isn’t a child of the camera, it gets recognised when I click on it, with this:

if (hitInfo.transform.gameObject.tag == "right")

However, when I make the gameobject a child of the camera (which i need to do) it is no longer recognised. Any ideas on what I can do?

Full code is:

    if (Input.GetMouseButtonDown (0)) {

    Vector2 pos = new Vector2 (Input.mousePosition.x, Input.mousePosition.y);
    RaycastHit2D hitInfo = Physics2D.Raycast (Camera.main.ScreenToWorldPoint (pos), Vector2.zero);
    Debug.Log (pos); // space indication
    // we have something under our pointer
    if (hitInfo) {
        if (hitInfo.transform.gameObject.tag == "left") {
            playerMovement += Vector2.left * distance; 

        if (hitInfo.transform.gameObject.tag == "right") {
            playerMovement += Vector2.right * distance; // or do something else


Try to make tags with no spaces like “FrontWheels”
rather than “Front Wheels”

I was having the same bug, but when I wrote it with no spaces, it magically worked?
Try it and tell me plz, so I could tell unity support

Note that Spaced tags does work for gameObject and parent but not with child.