You say you’re getting this error:
Nonexistent perform ‘get_node’ in base ‘SceneTree’
Nonetheless, I do not see you making an attempt to name get_node
on a SceneTree
in your code.
Anyway, the error could be appropriate. SceneTree
doesn’t have get_node
. As an alternative, it’s a technique of Node
. You would want to determine on which Node
you need to name it.
Some choices:
- On the present
Node
:get_node("blahblah")
, orself.get_node("blahblah")
. - On the guardian
Node
(withget_parent
):get_parent().get_node("blahblah")
. - On the
proprietor
(the basis of the scene that has theNode
):proprietor.get_node("blahblah")
. - On the basis of the
current_scene
:get_tree().current_scene.get_node("blahblah")
. - On the
root
of the scene tree:get_tree().root.get_node("blahblah")
. - Or another
Node
:varialbe_that_has_a_node.get_node("blahblah")
.
A few of these is likely to be the identical given the circumstance. However they’re completely different idea. For instance if the Node
is within the present scene (and never one other scene instanced inside it), then proprietor.get_node("blahblah")
and get_tree().current_scene.get_node("blahblah")
could be equal.
I do not know which one you truly wanted. I am not going into the reason of every one to maintain this brief. Please confer with the documentation.
Only for reference, the $
syntax is syntactic sugar for get_node
. In different phrases, this:
$CollisionShape.disabled = true
if well being < -20:
$AnimatedSprite3D.play("die")
Is identical as this:
get_node("CollisionShape").disabled = true
if well being < -20:
get_node("AnimatedSprite3D").play("die")
However sweeterâ„¢.
And sure, these are calls on the Node
on which the script is working.
As I used to be saying I do not see you name get_node
on a SceneTree
. As an alternative what I see you do is name get_nodes_in_group
, right here:
onready var nav =get_tree().get_nodes_in_group("NavMesh")
onready var participant =get_tree().get_nodes_in_group("Participant")
It’s good to bear in mind that get_nodes_in_group
returns an Array
. Nonetheless you appear to be utilizing the outcomes as in the event that they had been Node
s, right here:
find_path(participant.global_transform.origin)
And right here:
path = nav.get_simple_path(global_transform.origin,goal)
For those who had been utilizing static typing, Godot would have pointed that earlier. Sure, GDScript has sorts, use them.
Presumably there aren’t a number of of those Node
s in your scene. Right here some alternate options:
- You might take the primary merchandise from the
Array
fromget_nodes_in_group
. - You might get them from the present scene (assuming they are not in a deeper path). Like this:
get_tree().current_scene.get_node("blahblah")
. - You might use Scene Distinctive Nodes (the
%
syntax), and get them from the present scene. Like this:get_tree().current_scene.get_node("%blahblah")
. This lets you have them elsewhere on the scene. - You might retailer reference to them in an autoload.
Once more, sorry I am not explaining these deeper. Please confer with the documentation.