How do I make a Character Invisible

How do I make a NPC that can go invisible far away from the plaer but when it comes within range of any player it becomes un invisible?

I would suggest a shader that gets the distance to the player as parameter and uses it to change alpha value