Open git2013vb opened 4 years ago
What class does Map.gd
inherit from? get_node
is a Node
method. Most likely your class doesn't inherit Node or a derivate class.
@bojidar-bg @vnen Maybe we can make the error message clearer when $
is used in a non-Node class?
What class does
Map.gd
inherit from?get_node
is aNode
method. Most likely your class doesn't inherit Node or a derivate class.@bojidar-bg @vnen Maybe we can make the error message clearer when
$
is used in a non-Node class?
You right! I have nothing in first line but I had a extends Node2D before moving it
From my experience, this usually happens when inherited script has an error, so it can't be properly loaded.
I'm getting this currently with an inheritance depth of 3. Does inheritance just start to break down after a certain depth?
restarting the editor immediately took care of it... 🤷♂️
I just ran into the same issue. The class I was inheriting from was also called "Map" not sure if that has anything to do with it. As @MJBrune stated a restart of the editor did the trick.
restarting the editor immediately took care of it... 🤷♂️
It works!
I received this error when my inherited class (Unit.gd) wrongly called a method in the sub-class (Wolf.gd). I accidently put the function Death() in Wolf and then tried to call it from a function in Unit. Just a copy/paste issue but troubleshooting it was difficult because the error message (posted by op) doesn't help much.
Unit (extends KinematicBody2D) Wolf (extends Unit)
My guess is that what happens is that if your parent script has any error then the inheritance chain isn't detected, so the script doesn't know it's a Node. If you fix the parent script, then you have to re-parse the child one (by editing it, for instance) and that's why restarting the editor fix it.
The solution for this would be to add a clear message when the parent script is invalid for any reason. The editor should also re-parse scripts when they are selected, especially when there is any error.
I am having the same error: the class in question in AmmoPickup
and the inheritance "chain" is AmmoPickup
-> BasePickup
-> Interactable
-> StaticBody
, which is clearly a built-in, Node-derived type; also, all scripts have zero errors and are correctly loaded. But, since there's an error, any exported variable from any of those classes is hidden in the editor because "the scripts contains a mistake".
Like @MJBrune said, restarting the editor usually fixes the problem, although it eventually comes back again. The whole thing does look like a bug
@AndreaTerenz if you take @vnen's theory then reparsing from the base to the top child class should result in a fix. Essentially just having all the scripts open in the chain I've found can help. Go to each of them. I have the same situation with my interactable class and since keeping it open in the editor I've not had this issue with any child.
@MJBrune I tried that and it doesn't work. It's probably a bug in how the editor tries to climb up the hierarchy "ladder" to determine the methods and attributes of a class
Godot version: 3.2 beta3 OS/device including version: win7-64 Issue description: I have this error :
Error 15,1: The method "get_node" isn't declared in the current class.
in this line:onready var pos_spawn_enemy_mid:Vector2 = $Ground/SpawnPivots/EnemyMid.position
in terminal i have this error:
in debug dock I have this error:
Steps to reproduce: I moved the $Ground Minimal reproduction project: NA