ImBuilding is true error?

Godot Version

3.5.2

Question

Sup, Internet?

Hopefully a quick question. I was trying to make a bullet with an instantGeometry going out from a Raycast. Each time I hit the Fire button, I keep seeing “immediate_color: Condition “Im > Building” is true.”

I have not seen this issue before, what is the deal? Thank you.

extends RayCast

onready var cylinder = get_node("ImmediateGeometry")
onready var target = get_node("ShotDistance")

# Called when the node enters the scene tree for the first time.
func _ready():
	randomize()

func _process(delta):
	if Input.is_action_just_pressed('Fire'):
		shoot()

func shoot():
#	if get_node("../../SaveData").ammo > 0:
#		get_node("../../SaveData").ammo -= 1
#		print(get_node("../../SaveData").ammo)
	get_node("Timer").start()
	cylinder.set_color(Color.red)
	if is_colliding():
		cylinder.begin(Mesh.PRIMITIVE_LINE_STRIP)
		cylinder.add_vertex(to_local(global_transform.origin))
		cylinder.add_vertex(Vector3(rand_range(-0.1, 0.1),rand_range(-0.1, 0.1),get_collision_point().z))
		cylinder.end()
	else:
		cylinder.begin(Mesh.PRIMITIVE_LINE_STRIP)
		cylinder.add_vertex(Vector3(0,0,0))
		cylinder.add_vertex(Vector3(rand_range(-0.1, 0.1),rand_range(-0.1, 0.1),-5))
		cylinder.end()


func _on_Timer_timeout():
	cylinder.clear()

You need to set_color() for each vertex after begin() More info here Using ImmediateMesh — Godot Engine (stable) documentation in English

Same in Godot 3 as 4? Weird, I used this code before and it worked there.

Yes Using ImmediateGeometry — Godot Engine (3.5) documentation in English

That killed the error, thanks, but… stupid question, but why can’t I see the red line now?