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

and what will be the ouput ? The return value or the screen location ?

Position.

That boolean tells you if the projection is in the screen-space in the first place. If the component was behind you, there’d no need to draw the line, for example - you cannot see it anyway. So you can optimise on the performance front.

Where are you doing this - you will need context. is this in a widget?


This line drawing method works with widgets only:

I am in the first person context and have a static mesh as a blueprint. I attached the camera to the blueprint. My aim is to draw a line from the camera location to a faraway point like projection from the lens. I will attach the image



AND convertworldlocationtoscreenlocation is not availablöe in the event graph for this particular case.

This will not work, see above. You need a widget for this.

So can i add a widget to my blue print and add lines in that ? Does it work ?

Aye.

Unfortunately on paint doesnot exist in the function ovver ride
do we need to atttach any plugins to get the function.

You’re not in a widget. You need a widget for this. You’ve added a widget component. If you’ve never worked with widgets, consider watching a tutorial (or two) or reading docs - it’s a vast and convoluted topic.


As a kickstarter:

Open it and override onPaint as above. Add it to the screen in the Sedan blueprint:

You can now feed it data the onPaint function can take advantage of.

Yes, Now i created a widget blueprint from user interface and went to the on paint option. So i have to draw the lines here and add this widget to my original blueprint as a component ??

You could but it will require addition steps as you’d now need to peel the widget from the component to access it, which is done like so in the sedan blueprint:

Make sure the component is set to screen space.


The Forums Gods are not happy with me, stealth mode on for now


image

So in your opinion, what will be the best method to display the line ? Now I have the widget and alsso the sedan blueprint. Other than attaching the widget to the sedan blueprint, is there any way to draw lines from the location of a component of sedan blueprint.

PS: Sorry for too many questions, now in a full confused state and ‘The Forums Gods are not happy with me, stealth mode on for now
’

You wanted the lines to be occluded, so you should not be using widget painting. Best method for this is here:

Neat and efficient. I mean look at this:

Yea, Thanks for your suggestion. But in my case, i am doing an academic project and i have to do every method to draw the lines and also need to compare them. That’s why i am going through all the methods starting with the draw line method and if you are ok , can I ask another question
 :smiley:

1 Like

And i may probably caused a confusio here. Actually I need to draw the 3D line in the game play, not 2D line on the screen. So is this away also suited for 3D lines also as i can’t able to see the Z axis in the draw line function.

Perhaps this image (thread) represents the difference somewhat well:

The white lines are 2d and connect 3d coordinates through projection, no matter how far from the camera the coordinate is in 3d, the lines are of the same thickness:

The bottom bit is closer to the camera, yet the line is as thin as the top one.


Imagine the red arrows are what you refer to as 3d lines. Their size changes with perspective and with the distance to the camera. If you moved the camera very far away, those arrows would eventually disappear. The white lines will still be visible as they were even though they would describe a shape taking less space on the screen (because their 3d coords say so)

This goes back to the beginning of this conversant, a 2d line projected from 3d coords:

You can connect 3d coordinates with a 2d line.


Easy test with the HUD class:

image

Punch in crazy high numbers in one end and observe how it behaves.

1 Like

@Everynone In the thread you mentioned i guess they used the spline and spline mesh component. I got your point. But now I am exploring the options only with regards to draw lines option and i guess there is no such a method to draw a 3D line starting from a point to another in perspective view.

I alos know the method to draw lines using HUD and UMD but it won’t suite my case it does not work with occlusion. So i guess i have to move on from lines funtion to other options like spine or procedural mesh to draw the lines. Whats your take ?

You will need to go beyond what blueprints offer:

Also:

image

The functionality is locked beyond debug lines. Have a look at the animation (the red wireframe) in this post. 2d lines that respect scene depth.

Never dared to dig that deep but @Rama exposed it all in the Victory Plugin:

Before you proceed to any of the threads he frequents:

@Everynone Thanks for the information. As we came too much into the topic, now i am trying to start from the beginning of the discussion. I created the widget and now stuck with the SET in the below image. What does the SET specify here ? I can’t find in the event graph option


Variable promotion automates the process of creating new vars. Right click any data pin in blueprints and Promote to Variable:

Now you’ve set a widget reference variable which allows you to access the data inside the widget:


It can be done manually, too; create a new variable with + in the My Blueprint panel and set its type to be your widget in the details panel:

But nobody has time for all that clicking.


For all your variable needs:

1 Like