For a quick solution try this code (put it in it's own script). Some things don't work like line thickness but I've been using it a lot to test things in my game.
extends ImmediateGeometry
# class member variables go here, for example:
var m = SpatialMaterial.new()
var points = PoolVector3Array()
export(Color) var color = Color(1,1,1)
func _ready():
#Turn off shadows
self.set_cast_shadows_setting(0)
#set_material()
func set_material():
m.set_line_width(3)
m.set_point_size(3)
m.set_flag(SpatialMaterial.FLAG_UNSHADED, true)
m.set_flag(SpatialMaterial.FLAG_USE_POINT_SIZE, true)
m.set_albedo(color)
#m.set_fixed_flag(FixedMaterial.FLAG_USE_COLOR_ARRAY, true)
set_material_override(m)
func set_material_color(color):
m.set_line_width(3)
m.set_point_size(3)
m.set_flag(SpatialMaterial.FLAG_UNSHADED, true)
m.set_flag(SpatialMaterial.FLAG_USE_POINT_SIZE, true)
m.set_albedo(color)
set_material_override(m)
func draw_line(points):
set_material()
begin(Mesh.PRIMITIVE_LINE_STRIP, null)
for i in points:
add_vertex(i)
end()
func draw_line_color(points, size, color_par):
#set_material_color(color)
clear()
color = color_par
set_material()
if (size != null):
##set width
m.set_line_width(size)
m.set_point_size(size)
begin(Mesh.PRIMITIVE_LINE_STRIP, null)
for i in points:
#set_color(color)
add_vertex(i)
end()
To use it:
var drawLineFile = load("gdScriptLocation")
func someFunction():
var pencil = drawLineFile.new()
# this for me drew x and z axis
pencil.draw_line_color([Vector3(0,1000,0),Vector3(1000,1000,0)],3,Color(1.0,0.0,0.0))
someNode.add_child(pencil)