How to acces instance root

Godot Version

4.2.2

Question

i want to acces a property of my characters “root” node (not really the root just the normal “CharacterBody3D” node) from a node futher down the tree how do i do that without going over getParent().getPatrent.getParent … also because may change the hierarchy later how can i do that ?

I think unique names should do what you want.

%NodeName

No matter where in the scenes tree, via code you can always grab the object

for some reason i cant give the root node a %name

Another idea is to use owner.

Owner will be the scene instance root. It will only be set for node’s that were packed with that scene root.

2 Likes

Can you though if you right click on a child node?

-----EDIT-----
@indicainkwell has the best answer

@export var root: CharacterBody3D

Then in the inspector select your character node.

1 Like

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