Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Ruckus T-Boom |
An often recommended performance optimization is to remove get_node()
calls from hot code paths and instead move them to an onready var
. Does the same hold true for the $NodePath
literal syntax, or is it somehow optimized away?
Basically, my question is, does
_process(delta):
$Neck/Camera.do_stuff()
work exactly like
_process(delta):
get_node("Neck/Camera").do_stuff()
And, if so, is it recommended to use something like
onready var Cam = $Neck/Camera
_process(delta):
Cam.do_stuff()
This issue on github seems relevant:
Make the $ operator in GDScript cache node references (or add a $$ operator) · Issue #996 · godotengine/godot-proposals · GitHub
Lightning_A | 2020-11-19 05:52