Help with drawing line between polygons

Godot Version



Hello! How I could make a function that draws a line (border) between two polygons?

You can use an immediate mesh for this.
Something like this, but you might want to set a material and maybe set the transparency cullmode to disabled to see it from all sides. Or use a shader material.

extends MeshInstance3D

func _ready() -> void:
   draw_line(Vector3(0,0,0), Vector3(5,1,1)

func draw_line(p1 : Vector3, p2 : Vector3) -> void:
	mesh =

	mesh.surface_set_normal(Vector3(0, 0, 1))
	mesh.surface_set_uv(Vector2(0, 0))
	mesh.surface_set_normal(Vector3(0, 0, 1))
	mesh.surface_set_uv(Vector2(1, 1))


I guess there is also a way to do this completely with shaders, but I don’t know a lot about that…

Hello, and first I would want to tell you that I really appreciate your reply. But I meant for 2D polygons. And for detail I have lot of them, like 20 and I need line for each border of them. Thank you.

Something like this? (needs some tweaking :D)

Polygon with some points set up:

extends Polygon2D

func _draw() -> void:
	draw_polyline(polygon, Color.RED, 4)


Yes exactly!