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

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?

Particle beams is another.

2 Likes

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.

Beam is a totally straight line :wink:

1 Like

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…

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.

3 Likes

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.

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

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


Shakies in the vid due to :coffee: :coffee: :coffee: - apologies. :wink:


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.

5 Likes

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 ?

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.

2 Likes

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

Static mesh + wireframe material.

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.

2 Likes

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

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

1 Like

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.

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.

1 Like

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.

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.

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.

You’d need 3 splines:

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

and what you mean be occluded ?

image

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.