How do you guys resolve dependencies?

I have a path3d and a character3d(separate scene) attached as a child of this path3d, just so I can access it with getparent, the issue arises when I try this in the ready method it gives back Null. I can export it and set it in the editor then it works just fine.
what is wrong with my approach, and how do you guys deal with these dependencies? and how to structure projects in a way to avoid such things.
I wanted character3d to follow along the path3d, and switch to chasing player when provoked. should I just attach path3d as a child to character3d? this doesn’t sound good.

I like @export, stick with it!

In what way is having the Character3D a child of Path3D better?
IMO, it makes more sense that the path is the child of the Character.

You get null because the children of a node are created before the parent. So if you are going to keep the current parent/child setup then the @export is the best way to access the parent.

Yeah that happens because the parent can only be ready after the child is.

You’ll want to avoid referencing parent in the child’s ready function.
You can directly use child jode in script by drag&dropping the node to the script. It will show up as

you can call function from the object by simply using that as variable


I prefer to reference them with @onready, as it allows easier alterations when the hierarchy changes. You can do ot like this

@onready var MyCharacter:CharacterBody3D = $CharacterBody3D