How get_node works

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By VLAHIN

Hello. I’m interested in how the “get_node” is arranged inside. What is she really doing? Is it necessary to understand how best to use it, at the beginning of the script, put it in a variable or use “get_node” every time you call the function?

:bust_in_silhouette: Reply From: jgodfrey

Looks like get_node() mostly just calls get_node_or_null() internally. The source code for that is here, so feel free to take a look:

Regarding the second part of your question… A call to get_node() definitely takes some cycles, so… If you’re going to be referencing the same node multiple times in a script, it’s better to acquire that reference once and cache it in a variable for future use.