What difference does it make?

Hello folks,
I was wondering whether saving a reference inside a variable provides any value over just using the dollar sign to reference a child node directly in script? In the case of this lecture, why didn’t we just do this:

$RocketContainer.add_child(rocket_instance)

This is concise and saves us the effort of storing the refence.

hi,

as far as im aware for most projects the $ or the get_node is fine.
the benefit of storing references would be if you wanted to pass that reference to other scripts or if the scene heirarchy changes significantly where you would have to change all the get_node shortcuts for a different path, as opposed to a single location if its stored as a reference.

thats what springs to my mind.

Darren

2 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms