# What are the methods avaiable to draw lines in unreal engine?

**URL:** <https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [September 22, 2022, 10:57am UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052 "2022-09-22T10:57:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronyshaji1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ronyshaji1](https://forums.unrealengine.com/u/ronyshaji1)\
**Post date:** [September 22, 2022, 10:57am UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/1 "2022-09-22T10:57:20Z")

</div>

Hallo everyone,

I am exploring different methods to draw lines in unreal engine (my aim is to draw a rectangle projecting from a point using lines). I done some research and found some methods like using direct line method, debug draw, procedural mesh etc.

It will be helpful if someone tells anyother method or methods which we can use to draw lines in unreal engine with c++ scripts or any other way?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [September 22, 2022, 10:58am UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/2 "2022-09-22T10:58:53Z")

</div>

Particle beams is another.

---

<div class="post-metadata">

**Author:** ![ronyshaji1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ronyshaji1](https://forums.unrealengine.com/u/ronyshaji1)\
**Post date:** [September 22, 2022, 11:14am UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/3 "2022-09-22T11:14:16Z")

</div>

Hi @ClockworkOcean By line, i mean straight line. I huess particle beams is more for irregular lines. Anyway i will note that. I will be very helpful if you know anyother methods to draw/sketch line.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [September 22, 2022, 11:19am UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/4 "2022-09-22T11:19:52Z")

</div>

Beam is a totally straight line 😉

---

<div class="post-metadata">

**Author:** ![ronyshaji1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ronyshaji1](https://forums.unrealengine.com/u/ronyshaji1)\
**Post date:** [September 22, 2022, 11:57am UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/5 "2022-09-22T11:57:43Z")

</div>

Well…it is helpful for me. Do you have any experience with other methods i mentioned above like procedural meshes or draw debug. Any solution will be helpful to me…

---

<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:** [September 22, 2022, 12:09pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/6 "2022-09-22T12:09:08Z")

</div>

You can also draw lines in material. I mean, look at blueprints - the wires they draw. HUD can draw lines, UMG can paint lines. You can have a spline and a spline mesh component - can be expensive if used incorrectly but can also look pretty good, lots of control.

---

<div class="post-metadata">

**Author:** ![ronyshaji1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ronyshaji1](https://forums.unrealengine.com/u/ronyshaji1)\
**Post date:** [September 22, 2022, 12:36pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/7 "2022-09-22T12:36:52Z")

</div>

hey @Everynone I guess the lines using HUD is suppose only on the screen. I am looking to draw a forward line from a point just like a laser beam. Thanks for your input and may be you can also comment whether HUD lines can be used for my scenario.

---

<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:** [September 22, 2022, 12:43pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/8 "2022-09-22T12:43:20Z")

</div>

> [@ronyshaji1](#):
>
> suppose only on the screen

Project world → screen. The lines will be drawn in screen-space but connect 3d world coordinates.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/2/9/a29db6316e55bc3647722e1b51cea7a42cac408a.png)

UMG will give you more flexibility, though. Similar results.

* * *

_Shakies_ in the vid due to ☕ ☕ ☕ - apologies. 😉

* * *

> I am looking to draw a forward line from a point just like a laser beam.

Spline + SMC is OK, particles might be better. Depends on the desired fidelity / control. Absolutely try both.

---

<div class="post-metadata">

**Author:** ![ronyshaji1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ronyshaji1](https://forums.unrealengine.com/u/ronyshaji1)\
**Post date:** [September 22, 2022, 12:47pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/9 "2022-09-22T12:47:26Z")

</div>

So basically you are saying that we can draw lines from any point to another point usinf the HUD feature ?

In my case, i also need to include the Z cordinate also like line from (x=0.0, y=0.0, z=0.0) to a point (x=50.0, y=50.0, z=10.0). Is it possible with HUD ?

---

<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:** [September 22, 2022, 12:51pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/10 "2022-09-22T12:51:55Z")

</div>

Yes, as above. HUD or UMG. Both will work but work slightly differently. Go with UMG. The function you want to override is called `onPaint`.

---

<div class="post-metadata">

**Author:** ![ronyshaji1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ronyshaji1](https://forums.unrealengine.com/u/ronyshaji1)\
**Post date:** [September 22, 2022, 12:54pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/11 "2022-09-22T12:54:35Z")

</div>

I may be over asking, but in your opinion, what will be the best method to draw the rectangle shown in the attached image. I am thinking to go for lines, that makes the rectangle like a proejction. Is there any other methods available ?

![ray_casting](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/b/7/bb71448feec906dd567f19dee522852e9f80ea7b.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:** [September 22, 2022, 1:03pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/12 "2022-09-22T13:03:13Z")

</div>

Static mesh + wireframe material.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/8/a/58ae04d474ac64176b018130d4a8bd0ffd914490.jpeg)

Replaced the cone with a pyramid and you’re pretty close. Ideally, you’d create your own material for this. There’s a bunch of tuts online.

* * *

But drawing 2D lines with coordinates should also be ok. You could even add components to indicate the desired vertices - and draw lines off that. That should be pretty flexible and require no geometry whatsoever.

---

<div class="post-metadata">

**Author:** ![ronyshaji1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ronyshaji1](https://forums.unrealengine.com/u/ronyshaji1)\
**Post date:** [September 22, 2022, 1:08pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/13 "2022-09-22T13:08:17Z")

</div>

If possible can you explain what all things you used here ? From my understanding you created a static mesh box and a wireframe material. Or the wireframe material itself is a static mesh ??

Thanks for your time and information

---

<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:** [September 22, 2022, 1:09pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/14 "2022-09-22T13:09:51Z")

</div>

> [@ronyshaji1](#):
>
> From my understanding you created a static mesh box and a wireframe material. Or the wireframe material itself is a static mesh ??

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/b/f/6bf000f9730b342a88f4a78f171d62efc94513d0.jpeg)

And you can scale the mesh to achieve a more desired shape.

---

<div class="post-metadata">

**Author:** ![ronyshaji1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ronyshaji1](https://forums.unrealengine.com/u/ronyshaji1)\
**Post date:** [September 22, 2022, 1:14pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/15 "2022-09-22T13:14:37Z")

</div>

I kind of tried the same with the procedural mesh. But had some problem. Mainly using the wireframe material affects the physics ? i.e. when it collides with another object, does the physics of the car affected ?

Also in my case, i need a square pyramid instead of cone. I think it won’t be available in static mesh drop down.

---

<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:** [September 22, 2022, 1:15pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/16 "2022-09-22T13:15:08Z")

</div>

> [@ronyshaji1](#):
>
> when it collides with another object, does the physics of the car affected ?

Disable collision on the mesh.

> Also in my case, i need a square pyramid instead of cone. I think it won’t be available in static mesh drop down.

Make you own mesh and import it. Or use a brush and convert to static mesh.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/d/28d9f92c0b9c69d27fd7ccd0ca9761d6258c4fcb.jpeg)

---

<div class="post-metadata">

**Author:** ![ronyshaji1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ronyshaji1](https://forums.unrealengine.com/u/ronyshaji1)\
**Post date:** [September 22, 2022, 1:22pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/17 "2022-09-22T13:22:09Z")

</div>

Yea i got your point. Also in my case I need to change the length and width of the rectangle very much based on the angle between them. Is this possible using this method ? Also can i implement this using C++ as an API to change the values of the x,y, z coordinates.

---

<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:** [September 22, 2022, 1:28pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/18 "2022-09-22T13:28:47Z")

</div>

> Yea i got your point. Also in my case I need to change the length and width of the rectangle very much based on the angle between them.

For something dynamic, I would not use a static mesh. I mean you can scale it but it would get tricky / cumbersome. I’d probably use splines + spline mesh components if the lines are supposed to be 3d and occluded.

---

<div class="post-metadata">

**Author:** ![ronyshaji1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ronyshaji1](https://forums.unrealengine.com/u/ronyshaji1)\
**Post date:** [September 22, 2022, 1:33pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/19 "2022-09-22T13:33:51Z")

</div>

Is it works if i go with lines, where I can use multiple lines to join to form the pyramid. The spline and spline meshes are very new to me and may be it takes too much time to get a shape like that. and what you mean be occluded ? Yes line are in 3D as it extends from a point in space to another point.

---

<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:** [September 22, 2022, 1:41pm UTC](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052/20 "2022-09-22T13:41:34Z")

</div>

> [@ronyshaji1](#):
>
> The spline and spline meshes are very new to me and may be it takes too much time to get a shape like that.

You’d need 3 splines:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/d/4/ed41adf445a935837c00732bb37cece773871d98.jpeg)

The first one is closed. You can update it in real-time.

> and what you mean be occluded ?

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/a/7/5a73a50d0e7d422d26e12c3221cd4a1a3746fc4a.png)

They disappear behind geometry. Should they? If you were to draw them in screen-space, they would always be on-top, for example:

The HUD draws it on-top. It this was a spline or a particle, it would be occluded by the obstacle. There are ways of doing this is in 2d but its more involved.

[Next page](https://forums.unrealengine.com/t/what-are-the-methods-avaiable-to-draw-lines-in-unreal-engine/654052.md?page=2)
