0 votes

I use draw function to draw a line (I wanna make smt like those boards where you can look value of money n stuff ). I get two points, draw a line between them, and repeat this process. But everytime I draw a new line old one gets deleted. How can I prevent that from happening

Godot version latest
in Engine by (70 points)

1 Answer

0 votes

If you're using draw_line() inside a _draw() call, the buffer gets cleared as soon as you update again. To keep things drawn, you need to either:

  • keep track of all your draw calls and redraw everything when needed, or
  • use a Viewport with "render target clear mode" set to "never", and a ViewportContainer to actually draw the viewport on the screen.
by (1,305 points)

Do I have to use a script in viewport to make it work

The object that is drawing things inside the viewport (aka a child of the viewport node) needs to be the one doing the _draw() calls.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.