Debug Draw Line3D

Godot Version

4.2.2 ( c# )


I would like to know if there is an option to debug draw a line in a 3D environment.

Not built-in, but it’s pretty simple:

extends MeshInstance3D

@export var m_pntStart : Vector3 = Vector3.ZERO : get=getStart,set=setStart

@export var m_pntEnd : Vector3 = Vector3.ZERO : get=getEnd,set=setEnd

var m_color : Color = Color.GREEN

var m_material : ORMMaterial3D =

func _ready():
	mesh =
	m_material.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
func _process(delta):

func getStart():
	return m_pntStart

func getEnd():
	return m_pntEnd
func setStart(a : Vector3):
	m_pntStart = a
func setEnd(a : Vector3):
	m_pntEnd = a

func setColor(a):
	m_color = a
	m_material.albedo_color = m_color

func draw():
	mesh.surface_begin(Mesh.PRIMITIVE_LINES, m_material)

Yeah, there is no real built-in option.
Except when you are making a GizmoPlugin for some reason.

If you are planning on extensively using debug shapes, there is this great addon for that. It is made with GDExtension so its very good performance wise.

But if you don’t like to install addons, you can always make your own custom draw function like the above code.
I have made a video tutorial making a simple line renderer if you prefer that.