Is possible to use path 2d node witout drawing?

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

Hi! I’m new on godot, and as a blind person, I use a plugin which makes godot accesible for screen readers. Actually i’m doing the first game tutorial… but I can’t draw the points in the paht 2d node, because the plugin doesn’t have accesibility implemented for that. Is possible to do that in other ways? Thanks

:bust_in_silhouette: Reply From: whiteshampoo


The points from a Path2D node are defined in a Curve2D. This can be access via curve. You can add points with add_point(coordinate : Vector2) to the Curve2D

Here is a simple example how to make a “Z” (ZickZack) as a Curve2D for the Path2D:

extends Path2D

func _ready() -> void:
	curve.add_point(Vector2(0, 0))
	curve.add_point(Vector2(10, 0))
	curve.add_point(Vector2(0, 10))
	curve.add_point(Vector2(10, 10))

I hope this will help you.

thank you! so with the curve 2d i don’t need to close the curve like in the editor, right? If I script some path in ready I only have to write the curve positions?

yarkidius | 2020-11-03 15:21

You don’t have to close the curve in the editor. there is an option to close it, but that is optional. Just keep in mind that this is a “sharp”-curve, so no bezier-action or something is in action.

whiteshampoo | 2020-11-03 18:42