Draw a Line between two widgets

Ensure the Skill Icons are parented to a Canvas so you can get their positions:

The parent widget can draw lines using those coordinates. That’s the gist. The actual implementation would depend on whether this needs to be dynamic. Perhaps you can just draw lines in Gimp / Photoshop / Paint and slap icons on top in the UMG.

2 Likes

Draw a Line between two widgets

To literally answer it; this assumes we’re drawing from centre to centre:

342810-items.png

Image from Gyazo

Do note that lines render last (on top) so either draw from the edges / corners. Or have a separate background with lower Z order and draw there.

5 Likes

Hello, does anyone know how can i draw a line between 2 widgets ? so i can make a skill tree.

Thank you so much!!

I´ve tried that but the position b doesnt seem to be right.
Thanks for the quick response.

I’ll just add that for this to work (better) the widgets must have a Desired Size:

342818-screenshot-4.png

And the easiest way to have it reported correctly in the editor is via Size Box. It should work run-time one way or another since the layout will be pre-passed.

1 Like

Thanks!!!

This method does not work for cases where canvas is moved, i was experimenting with your given method and sadly nothing worked, then i tried out in c++ such method:


which basically given me almost same result as yours, but it moves with movement of canvas and zoom as well; thus said both methods are not correctly adding lines on the nodes:

The only time line semi-correctly is drawn on nodes, when i anchor nodes on whole screen:

in-game though happens such thing, since the screen resolution is different:

so, now i’m lost how to make correctly drawn lines between the nodes, as well as Z-index of drawn line should be under all other widgets…

alright, i figured out how to correctly draw a line, the only last issue that it is drawn on top of every UI widget/element…
I changed layer id of drawn lines, it still draws on one of the nodes and other under, as i can see it differs, so its unreliable to use for lines to make them under the nodes, what other solution there could be to make lines be under the nodes??


Could you try this adjustment?

tried just now, didn’t change anything.

ohh, maybe there is a z-order controlling the layer of widgets

well there is, but if i change inner canvas Z-Order to be lowest, the drawn line still will be on top of all the widgets…


as well when i change node Z-Order to any high value z-order, line is always on top:

(and i use InnerCanvas with OuterCanvas, so i could do panning and zooming logic on the nodes && lines)