Is there a way to detect if a raycast, is on the samy Y level as an entity?

Is there a way to detect if a raycast, is on the samy Y level as an entity?
Continue to help post