Howdy y’all, I’m kind of a noob here. How do I reference a node whose nodepath changes during the course of the script? I’m trying to a make a camera zone in a 3D game where, when the player enters it, the camera will switch to follow a set path at a different angle. I think I can do this by reparenting the player’s Camera3D child to be a child of the PathFollow3D, but now when I do that I can no longer use $Camera3D in the code to refer to the camera. Likewise, in other code outside the player scene, I use the camera’s full nodepath to reference the camera, and when the camera gets re-parented, the nodepath is now outdated and invalid.
Is there a way to reference the camera regardless of it’s path or parent?
@pennyloafers is right, store the node reference into a variable like var camera: Camera2D, or export to the editor with @export var camera: Camera2D for assigning node in the inspector view.