Why does this render 2 lines instead one ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wildboar

Again silly question, but I cannot figure out why does following code draw 2 lines instead one ?

func _draw():
if shooting and raycast.enabled:
	var raycast_collision_point = raycast.cast_to.length()
	
	if raycast.is_colliding():
		var collider = raycast.get_collider()
		if collider.has_method("hit"):
			collider.hit(damage)
		
		raycast.enabled = false
		raycast_collision_point = get_global_transform().origin.distance_to(raycast.get_collision_point())
	
	draw_line(raycast.position, Vector2(raycast_collision_point, 0), Color(234, 229, 52, 0.5), 1, true)
    
    shooting = false

func _on_RangedWeapon_attack_started():
 raycast.enabled = true
 shooting = true
 update()

func _on_RangedWeapon_attack_finished():
 raycast.enabled = false
 update()

Edit fixed somehow, not sure what exactly was the issue.

wildboar | 2021-03-01 14:28