How can I draw a curved line (or cylinder) that I can colour/texture in 3d space?

Hi all,

Could anyone provide me with a script that can draw a curved line (preferably a mesh as I want to colour/texture it)

I know 3 points in space (as seen in the image below)

What I want to be able to do is starting at point 1 draw a curved line through point 2 ending up at point 3.

Could anyone help me out I’m struggling with how to code such a solution.

I know it’s something to do with curves, splines, bezier curves etc, but it’s all just going a bit over my head.

(FYI: This isn’t homework :stuck_out_tongue: I want it for a teleport beam in my VR toolkit)

So you can use a Line Renderer to draw the line. You will need to provide it a set of points and it will generate a line mesh using them. It does not generate a curve though so you will need to do a little maths to generate the points that will give you a curve and then apply those points to the line renderer.
Here is something that may help generate the points or google for a tutorial.
There is also loads of stuff on the asset store to do this.

Thanks, I found an excellent tutorial at: Curves and Splines, a Unity C# Tutorial

Which helped me out and enabled me to implement what I wanted :slight_smile:

1 Like