How can I draw a random squiggly line? Need urgent assistance!!

Good Day All,

I would like to draw a constant random squiggly line at runtime.
Each time I run it, it needs to generate a new random squiggly line.
Preferably the line needs to keep drawing all over the place for about 5 seconds.

Please could someone assist me urgently, trying to get this project done and am struggling alot.
Thank you

Have you tried GL.LINES? Unity - Scripting API: GL.LINES

I don’t want to have to move a mouse or input anything.
I just want to be able to press a button and have the random line be drawn automatically.

GL.LINES has nothing do do with mouse input. Read the example again. They have an example that draws something based on mouse input, but you can make it do whatever you want.

A LineRenderer with positions being set randomly every Update is probably easier to do than futzing around with GL.LINES.

We could give more specific advice if you were more specific about your goal. Like, is this a lightning effect? Is it centered around a particular object, in a particular space, or literally covering the entire screen at random?

Well for art, have you ever heard of people taking a pencil and drawing a squiggly line over and around itself.
Then spend time looking at the mess to find some sort of form to start a drawing?
Well I want an automated digital version of this for myself.
I want to be able to click a button and have a random squiggly line drawn each time.
I have attached an example of what i want the result to look like.

5905985--630560--Line.jpg

I’d suggest getting a Bezier curve library off the shelf (Bezier Solution | Level Design | Unity Asset Store maybe?) and plugging some random x/y coordinates into the inputs. Tweak as necessary.

3 Likes

I would:

  1. Figure out how to draw a single line
    Unity - Manual: Line Renderer component
    Unity - Scripting API: LineRenderer.SetPositions
  2. Figure out how to generate a random coordinate
    Unity - Scripting API: Random.Range
    Unity - Scripting API: Vector3.Vector3
  3. Now draw a single line by generating two random coordinates for the start/end of the line
  4. Now add additional random vertices to make the line go all over the place
  5. Now you’ve got a lot of hard V shaped corners in the line, write a method for creating a series of vertices to generate a smoother curve to the line to replace the hard corners

Done

2 Likes

Thanks Joe, this sounds like a good idea. I am an Artist so this is all new to me.
I think maybe im trying to accomplish more than I actually know how to.
I will definitely attempt to try what you said, hope i come right :>
Thank you for the reply :wink:

1 Like