# Draw a Line between two widgets

**URL:** <https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568>\
**Category:** UI\
**Tags:** unreal-engine, UI, question, UMG\
**Created:** [June 30, 2021, 11:52am UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568 "2021-06-30T11:52:13Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlashCodX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FlashCodX](https://forums.unrealengine.com/u/FlashCodX)\
**Post date:** [June 30, 2021, 11:52am UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/1 "2021-06-30T11:52:13Z")

</div>

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

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/7/1/971f0b3b42c3aa27a64aa1caf006a98ba812b393.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 30, 2021, 12:01pm UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/2 "2021-06-30T12:01:35Z")

</div>

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

 ![342809-screenshot-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/6/9/069ab4ddab59dccdb2f50f2bb19c77aa93430ca7.png)

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.

---

<div class="post-metadata">

**Author:** ![FlashCodX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FlashCodX](https://forums.unrealengine.com/u/FlashCodX)\
**Post date:** [June 30, 2021, 12:22pm UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/3 "2021-06-30T12:22:38Z")

</div>

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

 ![342826-ui.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/b/7/5b7cab80f751d42ee0dda0511902f8e0840d2471.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 30, 2021, 12:24pm UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/4 "2021-06-30T12:24:40Z")

</div>

> Draw a Line between two widgets

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

![342810-items.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/d/8/fd86a348f61a98188ba799fa389c92ac15a41e78.png)

 ![342831-screenshot-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/7/5/f754553e3c26b90d41ccd92143866defbe06f347.png)

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/e/5/ee566111e04bc55abf2903e6b5a9c53f60d150f5.gif)](https://gyazo.com/f87607■■■91cf7344c376f04c7c29482)

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.

---

<div class="post-metadata">

**Author:** ![FlashCodX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FlashCodX](https://forums.unrealengine.com/u/FlashCodX)\
**Post date:** [June 30, 2021, 12:30pm UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/5 "2021-06-30T12:30:33Z")

</div>

Thank you so much!!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 30, 2021, 12:37pm UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/6 "2021-06-30T12:37:54Z")

</div>

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

 ![342817-screenshot-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/c/4/0c41e6f06cc44b621a26ef8bca7a471f476243b2.png)

![342818-screenshot-4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/8/7/587551e0b59df17eaae88098c800b0dc77935266.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.

---

<div class="post-metadata">

**Author:** ![FlashCodX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FlashCodX](https://forums.unrealengine.com/u/FlashCodX)\
**Post date:** [June 30, 2021, 12:51pm UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/7 "2021-06-30T12:51:13Z")

</div>

Thanks!!!

---

<div class="post-metadata">

**Author:** ![Justrenis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Justrenis](https://forums.unrealengine.com/u/Justrenis)\
**Post date:** [November 16, 2024, 11:45am UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/9 "2024-11-16T11:45:22Z")

</div>

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/e/e/6ee8b8bfd78255f8adbfea162f78a86e66556d3a.png)  
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:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/b/2/bb2966880978454ef5295170bc78f1a4da5c5d95.png)  
The only time line semi-correctly is drawn on nodes, when i anchor nodes on whole screen:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/6/4/964fe495963b15bbd873194b5321b8d9d0324be7.png)  
in-game though happens such thing, since the screen resolution is different:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/e/8/1e84ba13306dec00d9203176614bb246ad06218c.png)  
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…

---

<div class="post-metadata">

**Author:** ![Justrenis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Justrenis](https://forums.unrealengine.com/u/Justrenis)\
**Post date:** [November 17, 2024, 11:02am UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/10 "2024-11-17T11:02:00Z")

</div>

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??

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/d/b/7dbc7228ea33460ba59713575200de0f8f8c6b34.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/3/c139e489a7adc13fd56ef47906e3742452af1a25.png)

---

<div class="post-metadata">

**Author:** ![tootzoe1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tootzoe1](https://forums.unrealengine.com/u/tootzoe1)\
**Post date:** [November 17, 2024, 1:36pm UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/11 "2024-11-17T13:36:22Z")

</div>

![rr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/7/9/c79b4f672dd7e17c68b003864391811a3f900158.jpeg)

Could you try this adjustment?

---

<div class="post-metadata">

**Author:** ![Justrenis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Justrenis](https://forums.unrealengine.com/u/Justrenis)\
**Post date:** [November 17, 2024, 1:51pm UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/12 "2024-11-17T13:51:34Z")

</div>

tried just now, didn’t change anything.

---

<div class="post-metadata">

**Author:** ![tootzoe1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tootzoe1](https://forums.unrealengine.com/u/tootzoe1)\
**Post date:** [November 17, 2024, 2:21pm UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/13 "2024-11-17T14:21:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Justrenis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Justrenis](https://forums.unrealengine.com/u/Justrenis)\
**Post date:** [November 17, 2024, 2:26pm UTC](https://forums.unrealengine.com/t/draw-a-line-between-two-widgets/485568/14 "2024-11-17T14:26:14Z")

</div>

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…

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/7/d/37d7ceacccbccfbf314fde8dfe55813fb3fad300.png)  
as well when i change node Z-Order to any high value z-order, line is always on top:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/f/5/ef5effbf9eb50e6b18565d1658c8be66da2f0f06.png)  
(and i use InnerCanvas with OuterCanvas, so i could do panning and zooming logic on the nodes && lines)
