- Home /
Question by
jakejolli · Jun 07, 2017 at 07:19 PM ·
2duilinerenderer
Circular Position Offset
I'm creating a skilltree system, and I'm drawing lines between my child and parent nodes.
Currently, I'm just drawing the line from position to position, but because my nodes have some transparency, you can see the line in behind, and it looks like garbage:
Instead, I want my line to draw from circle edge to circle edge. I know I want to offset the start/end positions of my line by the radius of my nodes, but how do I determine the correct x/y offset amounts based on the angle of the line?
capture.png
(9.9 kB)
Comment
Best Answer
Answer by Bunny83 · Jun 07, 2017 at 07:32 PM
Simply do this:
Vector3 p1;
Vector3 p2;
Vector3 dir = (p2 - p1).normalized;
Vector3 start = p1 + dir * radius;
Vector3 end = p2 - dir * radius;
Here p1 and p2 are your node positions and radius is your node size.