raycast problem (or any other solution)

Hi,
I want to display enemy’s stats on my GUI when I’m looking at it.
I don’t want to display enemy’s HP above it because when I’m near him I can’t see it.

I think that enemy can somehow ‘feel’ raycast and find out it’s source and send message to it with his stats. Any ideas? Or other solutions?

Are you a beginner?

I wouldn’t ray cast, i’d check the distance between my player and the enemy, then I’d use Camera.WorldToScreenPoint, then change that in to GUI space.