ControllerAIHumanoid.IsInFieldOfView C# (CSharp) Method

IsInFieldOfView() private method

private IsInFieldOfView ( GameObject obj ) : bool
obj GameObject
return bool
    internal bool IsInFieldOfView(GameObject obj)
    {
        //Setting Height
        Vector3 direction = (obj.transform.position  - (this.transform.position + Vector3.up));

        Debug.DrawRay(transform.position + Vector3.up, direction,Color.black);

        float angle = Vector3.Angle(this.transform.forward, direction);
        if (angle <= fieldOfView * 0.5f)
        {
            RaycastHit hit;
            if (Physics.Raycast(transform.position + Vector3.up, direction.normalized, out hit, hearingCollider.radius))
            {
                Debug.DrawRay(transform.position + Vector3.up, direction);
                if (hit.collider.gameObject == CurrentEnemy.transform.parent.gameObject)
                {
                    return true;
                }
            }
        }
        return false;
    }
    void OnCollisionEnter(Collision coll)