Topic was automatically imported from the old Question2Answer platform.
Asked By
serge059
It’s a very basic question but I don’t know if I’m doing things the right way.
To modify the name of a node for instance, I see that many people use the set_name() function but I don’t see this function in the docs and myNode.name = “newname” works too.
So, to access a member variable, do we have to use a set-get function or can we safely read or modify them directly ?
You can use setters or getters with your scripts, or you can access them directly. GDscript is pretty flexible like that. What you need to figure out is which method works best for your situation. If you find that using setters or getters works best for you (so that the member variables are protected), then go with that. If you require a more “hands-on” approach, and need to change or access the member variables directly, that’s fine, too.