UMG Socket Lines

Hello, I am trying to create a slot based attachment system for my weapons and i need to visualise what attachment goes into each slot.I need a way to draw a line from the weapon socket to the desired slot without making the slots world widgets.
ex: Sight Socket line going to the center of the Sight Slot.

What are world widgets? Do you mean widget components?


  • create sockets on the weapon mesh
  • create widgets for the attachment
  • have a full screen widget with just a canvas and use it for painting lines
  • add the attachment widgets to the viewport or to the above-mentioned canvas
  • use canvas’ onPaint to draw lines from the attachment widget (as Canvas Slot or use Viewport Position) to the deprojected socket location on the weapon mesh

Thank you for you answer,but I realised that I asked the wrong question,the onPaint function seems to be the solution,but I couldn’t get it to work in my case,because I am using a Render Target to capture the weapon and then render it to UMG.I don’t suppose there is a solution to get the lines directly from there and I can’t paint them manually because I need to be able to rotate them with the weapon.

The image helps.

I think it’s still doable but the render target will make it more difficult since you’re now dealing with a bunch of pixels rather than actual world coordinates.

Since you have it all set up nicely already, consider the following:

  • add the sockets to the mesh as mentioned above
  • translate their location into 2d screen coords using Map to Range node
  • use the mapped coordinate as the line end

Now that I can see precisely what you’re attempting and how it’s set up, there are several problems with this:

  • it’s unlikely to be pixel perfect and may be jiggly and slightly inaccurate
  • you will most likely need a separate set of offsets for each weapon
  • the lines will cross if you rotate the object (unless you have only 1 at a time)
  • the above will require you to sort the slots in the panel at the bottom (a bit tricky but doable)
  • since you’re using a container for slots, you can’t get their position directly - you’ll need additional calculations to get the positions of the slots locally (it can be simplified by painting on this very widget only); I imagine you do not want the lines to ever leave this space anyhow.

This all sounds pretty complicated. UMG is not geared towards this. Not using render targets makes it easy, though.

Thank you for all the help, It should be enough to get it working either way, this was very helpful.