How To Change Line Renderer Color Based on Length

I have a line renderer in between two points and want to change it’s color between two based on the distance of the objects. How do I do that?

Perhaps use the result of Vector3.Distance(); based on those two points and look up a resulting Color in a Gradient object, which is essentially a color ramp you can edit in the inspector.

Please don’t use the 2D-graphics tag unless you’re asking specifically about 2D features i.e. Sprites, SpriteShape etc as this puts the question in the 2D product area. The LineRenderer is 3D even if you don’t use Z.

I’ll remove the tag for you.

Thanks.