- Home /
Draw line from one point to another using mouse
Hello everyone..
I have scene like points will be generated randomly and i want to draw line in between those points.
So if i touch on any of the point i want to start that line and line should be drawn till i reach to the another point. Thats the way i want to draw line.
And if i could not be reached to another point then line should not be drawn.
Line should not overlap each other and new point also we can add by dragging line . How can i achieve this ??
Thanks to all for your help and support till now..
You bumped this, so I'm assu$$anonymous$$g you are still looking for an answer. Right now this question is too vague with multiple issues. You need to break your problem into individual issues:
How to display a line
How to connect points with a line
How to display the points
How to randomize the placement of the points
How to detect a near point to connect a line
How to avoid overlapping a line (can two segments share a point? Can a segment cross another line segment?)
How to select a line
How to drag a line
I'll give a bit of feedback on one aspect of your question: drawing lines. There are multiple ways of drawing a line, all with their strengths and weaknesses, and many are not very simple. Here is a partial list.
LineRenderer
Use real world objects line Quads or Cylinders
GL class
Vectrosity
The last one, Vectrosity, is a paid-for script in the Asset Store. You could draw all of your points and all of your lines in a single drawcall, and there is a bit of starter script that draws a line by clicking with the mouse.
Here I m giving a code for draw a line through mouse. It will deferentially worked.
Your answer
Follow this Question
Related Questions
Drawning Line Problem useing custom class 1 Answer
How would I replicate Gizmos.DrawLine in-game? 1 Answer
A node in a childnode? 1 Answer
Need Help with How to make a Game like Canvas rider... 0 Answers
interesting raycast question 2 Answers