- Home /
Question by
shahanbutt0 · Nov 16, 2018 at 09:10 AM ·
unity 2dlinerenderer
Draw over using Line Renderer 2D when hitting a collider
I am using LineRenderer 2d. I can draw a line by getting mouse position but it draws over a gameobject with collider. What i want is when the line should stop where it hits a collider but draw on the edge and move in the direction of mouse position. The line can hit a collider from any direction.
this is my current code:
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
listPoint.Add(mousePos);
currentLineRenderer.positionCount = listPoint.Count;
currentLineRenderer.SetPosition(listPoint.Count- 1, listPoint[listPoint.Count - 1]);
ezgifcom-optimize.gif
(180.5 kB)
Comment