How to set width of specific segments of the linerenderer at runtime using code

Hi There,

I cant seem to figure out how to do this, I want to be able to set the graph below from the code during runtime. I found Unity - Scripting API: LineRenderer.SetWidth which is obsolete, and it told me to go to Unity - Scripting API: LineRenderer.widthCurve or widthStart or widthEnd. I cant seem to understand what the documentation is saying widthCurve does (Set the curve describing the width of the line at various points along its length), so I cant tell if it is what I am suppose to use for this. Could someone help explain to me what it does or if there is a different thing I should use?


Sincerely,
Kyle Brim

It’s an animation curve just like that red line in the screenshot. For example if you wanted the width at position 0.0 to be 1.0f.

var curve = new AnimationCurve();
curve.AddKey(0.0f, 1.0f);
line.widthCurve = curve;

Thank you so much for your response, this will work perfectly :slight_smile: It definitely makes sense now, I think I just looked at it too long last week and my brain broke :slight_smile: