0 votes

I'm wondering about the efficiency of using get_node() in process() every frame. I see many code examples do this, but is it okay? I usually use get_node() once and store the node reference in a variable, but is it fine to skip that and just use get_node() all the time?

asked May 29, 2017 in Engine by yepbear (29 points)
edited May 29, 2017 by volzhs

2 Answers

+1 vote
Best answer

When I know the node is always going to be here, I get_node once and use the variable afterwards, using onready if possible. Because it has a cost, very small, but existing. I also like to separate node name and variable name, so that it's cleaner to write and changing the name of the node doesn't become a copy/paste hell.

answered May 31, 2017 by Zylann (26,143 points)
selected May 31, 2017 by yepbear
0 votes

I don't know if is "faster" and most people use instance variables just for readability, but for OOP design, if it is not a class property just get it when you need it in the scope where it is used (a specific method).

Is the ideal on any form of structured programming too.

answered May 29, 2017 by eons (7,764 points)
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 How to use this Q&A? before posting your first questions.