0 votes

How can I change the colour and width of a Line2D node through code?
Does it have Methods to call to give effect to colour and width change? Or, does this happens only through the Inspector?

related to an answer for: Drawing a polygon 2d
in Engine by (101 points)

1 Answer

+1 vote

You can access its properties as you can do in all other nodes.
For color for example is this:

default_color [default: Color( 0.4, 0.5, 1, 1 )]
set_default_color(value) setter 
get_default_color() getter

https://docs.godotengine.org/en/stable/classes/class_line2d.html

by (222 points)

Thanks. This works

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.