Easy Curved Line Renderer [Free Utility]

Earlier today I discovered AnimationCurves and was experimenting with their usefulness when I discovered how to easily smooth out any set of positions, and so it is also very easy to create some simple Curved Line Renderers!

Included:

LineSmoother.cs

  • main utility script for smoothing out positions
  • static function so it can be accessed without being attached to a gameobject
  • feed it an array of Vector3 and a segment size and you will get back a smoothed out array!
  • segment size is world space and so the number of line segments in between points adjusts based on distance between points

CurvedLineRenderer.cs

  • example use case for smoothed out positions
  • add new points and it will automatically update to include the new position!
  • example scene is provided with a regular curved line and a curved line with physics applied to each point

CurvedLinePoint.cs

  • draws gizmo and sends back to CurvedLineRenderer to update line when the point is moved

And because I think this is useful, and because I always enjoy when others post free stuff, I am giving this away for free! :slight_smile:

2550312–177294–CurvedLine_2016_03_11.zip (14.2 KB)

72 Likes

This is a really neat little utility! :slight_smile:

I could see people coming back to this post for a while whenever they need something like this.

It seems one of those things a lot of people have thought “that would be nice to have”, but never sat down and wrote.

Glad it is useful! :slight_smile: Are there any other tools that you have thought “that would be nice to have”?

THANK YOU!

True, more than a year has passed and I already found it useful :slight_smile:

If you have a visual editor to handle the points in real time it would be great, it’s not that much user friendly when you have to do a precision curve, but it’s just a “nice to have” thing really :slight_smile:

Awesome !

Thanks man, this tool is awesome

1 Like

Thanks a lot for this tool :slight_smile: After struggling for some time to draw curves for objects to follow, you helped the noob i am so much !
I just changed this to make them grow :

// 2 public variables instead of 1 for width
    //public float lineWidth = 0.1f;
    public float lineWidthStart = 0.1f;
    public float lineWidthEnd = 0.1f;

// then used in SetPointsToLine()
            //line.SetWidth( lineWidth, lineWidth );
            line.startWidth = lineWidthStart;
            line.endWidth = lineWidthEnd;

Which then allows me to use the Width curve in the editor to finetune the growth
3308475--256846--upload_2017-12-2_11-16-46.png

Thanks again

2 Likes

this looks great, but what version of Unity is it for? It does not load with 2017.3

I successfully used this very useful package (thanks a lot @Haagndaaz_1 !!!) with Unity 2017.1, 2017.2 and 2017.3.
I also made some changes to make curved lines look like their were solid (wires or pipes).

Here you can find a screen capture and a package made with Unity 2017.1.2f1 (also tested in Unity 2017.2 and 2017.3).

3397585--267478--Unity 2018-02-20 11-16-25-81.gif
3397585–267479–CurvedLine-2017.1.2.unitypackage (81.6 KB)

5 Likes

Whoa! Glad you liked it and great job in improving it @G_P_V :slight_smile:

1 Like

Wanted to say thanks too :slight_smile: Found it very useful in my little Kinect game, generating an elastic line between a character and their thought bubble. Threw a thought bubble material on the line and voila!

Thank you for sharing this cool resource ! It’s very useful for a project I’m working on. I wanted to know if it’s possible to change the Line Width of a specific Line Point instead of the global Curved Line. I basically want it to get thiner at the end of it. Do you know how I could do that ?

Done!
I added a flag useCustomEndWidth (Use Custom End Width in Editor) to enable a different line ending (set to false by default to not affect the previous version), with an additional endWidth field to be set if the previous flag is set to true (Use Custom End Width checked). I also updated the example scene to demonstrate this feature.
Here you can find a screenshot of these changes and the updated package:

3497386--278665--Unity 2018-05-15 10-12-42.png
3497386–278666–CurvedLine-2017.1.2.unitypackage (110 KB)

3 Likes

Perfect ! Thank you very much for this update ! Helps a lot :slight_smile:

Should put this on the asset store for free, it’s a very neat utility

1 Like

thank you ,it’s helpful!!!

1 Like

Please can you provide me 5.4 version of it.

This is really aweseom and i am looking for. But i imported the package in unity 5.4 it is not working. the error i have remove but there is no object at all.

@MFKJ The version you are trying to use was specifically developed upon Unity 2017.1 and above, it does not work with previous versions because of the lack of line texturing feature. Anyway you can still use the original version by @Haagndaaz_1 .