How to draw a continuous line based on changing node position?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By godot1776
:warning: Old Version Published before Godot 3 was released.

What i am looking to do:

There is a dot that travels across the screen when a Button is pushed.

Now i want that dot to leave a trail (draw a line) as it travels.

I understand how to get the button connected, but i am struggling with the code of the drawing of the line?

Is it just a line it should draw, or should the line animate or fade in some way?

Zylann | 2017-02-02 01:47

:bust_in_silhouette: Reply From: Zylann

Some info is missing about how you want this line to behave, but this question might interest you How to create a 2d trail - Archive - Godot Forum

Also, the custom drawing section from the docs.

Custom drawing in 2D — Godot Engine (stable) documentation in English

eons | 2017-02-02 18:17

thanks, i think i might be able to use that link to help.

I Do not want the line to fade. I would like it to behave like this.

Button A - plays animation of dot moving across screen, and draws a line (trail) of the path the ball is taking. (this line only goes away when another button is pushed)

Button B - Plays animation of the same dot taking a different path across screen while drawing the new path.

godot1776 | 2017-02-02 18:56

Custom drawing with _draw() is what you are looking for then :slight_smile:

Zylann | 2017-02-02 21:27