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!
True, more than a year has passed and I already found it useful
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
Thanks a lot for this tool 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
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).
Wanted to say thanks too 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:
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 .