Reputation: 221
I have a class named UnitDeckCard. It inherits from DeckCard, which inherits from TextureRect. My issue is that, in the UnitDeckCard, I'm trying to define an onready var with a node from the scene:
onready var cost_label = $CostLabel
But then I received an error The method "get_node" isn't declared in the current class
I thought that, since, by inheritance, UnitDeckCard inherits from a Control class (TextureRect class), get_node method would be available, as Control inherits from Node (get_node is a Node method). As I undestand, my case would be something like that:
UnitDeckCard < DeckCard < TextureRect < Control < CanvasItem < Node < Object.
Why can't I use get_node method in UnitDeckCard?
Upvotes: 1
Views: 2244
Reputation: 221
It seems that I just needed to exit the project and open it again. Some sort of bug from Godot Engine, I guess.
The only notable thing I can say is that I wasn't using direct class names. UnitDeckCard was extending DeckCard using the script path extends "res://deck_card_script_path.gd"
, then I started to use class_name and extending using the class name extends DeckCard
instead of using the script path. Anyway, no idea what was throwing the error exactly since the inheritance should've worked in the first place.
Upvotes: 2