`draw_line` in Wrong Place With Wrong Colour

Godot Version

v4.2.2.stable.official [15073afe3]

Question

I am trying to draw some lines to display the steering forces being applied. The most obvious issue is that the line is set to draw in green, but is drawing black. It’s such an immediate issue that I assume I am missing something. The second issue is that one end of the line should be on the Actor node creating the line, but it is significantly offset. Due to trying both position and global_position shouldnt at least one end of the line have been attached to the Actor?

Code to draw line:

## actor.gd
func _draw():
    draw_line(position, _debug_info["target"], Color.GREEN, 1.0)
    draw_string(_debug_font, _debug_info["target"], "T", HORIZONTAL_ALIGNMENT_CENTER, -1, 8, Color.GREEN)

Using global_position:
Godot_v4.2.2_1vSxhEAGq6

Using (local) position:
Godot_v4.2.2_GIg0k8Lwk9

Hi
_draw function draws in local space where the drawing origin is the origin of the node.
draw_line( Vector2.ZERO, _debug_info["target"] - global_position, Color.GREEN, 1,0 )

Salud!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.