Possible issues when renaming and string literals Nodes

Hi, first of all, thanks, everything is great and useful for someone starting with Godot and coming from Unity

I would like to know if there is any best practice to ensure the Node can be renamed without causing some serious bugs or exceptions in the game, I tried different ways and the only one that seems to be safe is to use:

@export var rocket_container_path:NodePath
@onready var rocket_container = get_node(rocket_container_path)

That way you can use the Path reference in the editor itself and, if renamed, the reference will continue to be the correct one.

Is there an alternative to this, that can make it shorter to code but still be safe when renaming?

I tested all the alternatives shown in this lecture and, if you rename the RocketContainer node, it doesn’t work properly afterwards.

Thanks in advance!

Privacy & Terms