Raycast from child?

Hello everyone!

I am having a problem shooting a raycast from a child gameobject;

I have an empty gameobject in front of the AI’s eyes to represent a cone of vision.

I set it up properly in the awake

private GameObject coneOfVision;

void Awake()
    {
        coneOfVision = transform.Find("ConeOfVision").gameObject;
    }

a call it in a later function like this

Vector3 direction = enemy.transform.position - coneOfVision.transform.position;
        float angle = Vector3.Angle(direction, transform.forward);
       
        if(angle < fieldOfViewAngle * 0.5f)
        {
            Debug.Log ("Correct Angle!!!!!!!!!!");
            RaycastHit hit;
           
            if(Physics.Raycast(coneOfVision.transform.position, direction.normalized, out hit, Mathf.Infinity))
            {
                Debug.Log ("raycast shot");
            }
        }

I get a debug of “raycast shot” when I just use transform.position but I do not get it when I try to use the coneOfVision.transform.position…

Maybe use debug to draw the line and look to see where it’s going.
Also make sure your not ignoring raycast on layers.