I am using mouse position to draw a line using line renderer 2d. What i want is when the line hits a collider it should start to draw on the edge of the collider rather than over the collider. Something like this:

enter image description here

The line renderer will still draw using mouse position. It will just draw on the edge of a collider and move in the direction of mouse postion.

  • 2
    \$\begingroup\$ When it gets to the end will it conform to the shape of the collider to reach the mouse position or will it simply extend in a straight line? If the former, maybe some A* path finding could help. Cool gif btw. \$\endgroup\$ – mr-matt Nov 19 '18 at 8:08
  • \$\begingroup\$ it will conform to shape of the collider to reach the mouse poistion \$\endgroup\$ – Shahan Butt Nov 19 '18 at 8:20
  • \$\begingroup\$ Have a search on google for a* pathfinding, I think that will solve your problem. There's tonnes of tutorials on youtube. \$\endgroup\$ – mr-matt Nov 19 '18 at 8:36
  • \$\begingroup\$ @mr-matt could help me with the code of this , i am still stuck on this \$\endgroup\$ – Shahan Butt Nov 27 '18 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.