0 votes

I understand how to draw a line using the godot draw_line function. However, what I am wondering is is there a why of making that line more details. For example by adding depth by shading the sides slightly, as if to make it look like a tube. A good example of the detail I would like to replicate are the lines you would use to connect nodes in the node editor in blender?

Thanks in advance!

in Engine by (295 points)

there is similar functionality, but it will be with 3.0

You can use shaders over lines drawn by _draw, but I have no idea how to get things like the UV or position (modifying the CanvasItem rect, maybe?).

May be easier to simulate a line with a polygon.

1 Answer

+2 votes
Best answer

An easy solution that works really well (i use it myself) is to draw two lines on top of each other.

The trick is to set the opacity on both lines at ½ the final opacity, fx 0,5 if you want a solid line, and making one line a bit bigger that the other.

draw_line(from_pos, to_pos, Color8(255, 255, 255, 255/2), 4)
draw_line(from_pos, to_pos, Color8(255, 255, 255, 255/2), 3)

Before and after example from my game (Code above is just an example, not exactly what i use):

enter image description here

enter image description here

I am not 100% sure this technique can work for your exact needs but i thought i would throw it out there anyway ;)

by (306 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.