Draw a line between two actors without using DrawDebugLine

Hi!

I’m using Unreal Engine 5.2 with C++ and Blueprint.

I want to draw something like this on a level:

imagen

The actors will be 3D spheres. I will put the spheres programmatically with C++ and then add the lines to join each other.

How can I do it?

Thanks!

To do this you can simply use DrawDebugLine using the world locations of the two spheres as parameters.

I’ve set the duration to be 0 (it’ll need to be called every frame to be visible) so it’ll update with any change, but if you know how long it’ll be up on screen and don’t want it to change, you can change that duration to be whatever you need.

Thanks, but if I don’t want to use Debug lines. How can I do it?

An easy alternative would be using a spline.
You can use as many points as you want, but to create a line you can just use two with the same rotation
Here’s a video explaining them:

Depends if the line itself is 2d or 3d. Browse this thread for options:

A ribbon particle could look and perform better than a Spline Mesh Component. But a SMC would give you more flexibility. What method to choose depends on what this is going to be used for.

do you want to draw a line in screen space?

It will be 3D.

I’ll try ribbon particle, but I’m a bit worried about performance because it could be more than ten lines at the same time.

Thanks.

Thanks, but sorry, I don’t understand you: What does mean “screen space”?

Thanks.

I think you could get away with 10k ribbons. They’re pretty fast.

1 Like

Screen space = 2D. Check the thread I posted, plenty of examples of both.

1 Like