Thanks for the reply.
I'm actually more confused about how to smoothly fade between two colors based on that distance.
For example, at a distance of 5 it starts to fade to the new value based on how close you get. If, for example, you get further away again, it starts to fade back to the original color.
I could do this with a Color Ramp, but the color ramp will only work between 0-1 values, or 1 and 2. I don't know how to map my distance values in a normalized way like this.