![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | MRIG |
Hi there. I’ve been investigating this for a little while but still have no idea what the difference is between these two methods of creating and displaying a Line2D:
- Creating a Line2D as a sub-node of the base Node2D in the Godot GUI.
- Attaching a script to the base Node2D and creating the Line2D within its _ready() function. The GDScript code in question:
.
func _ready():
var line = Line2D.new()
line.add_point(Vector2(40, 40))
add_child(line)
Only the former of these works and displays a line. What am I doing wrong in the second method?
As a side note I’ve also been unable to draw a line using draw_line() from within the base Node2D _draw() function:
.
func _draw():
draw_line(Vector2(0, 0), Vector2(40, 40), Color.AQUA)
Thanks for the help
P.S. I’m not sure why the code block isn’t indenting the lines after line one.
Edited to fix code formatting (via the { }
button). However there is some code block rendering bug if the block immediately follows a bullet list. My fix for that has always been a lone .
just before the code block…
jgodfrey | 2023-04-28 22:30