get_node isn't declared in the current class

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bnfgh
extends Ship
class_name Enemy

onready var timer = get_node("Timer")

error (6,1): The method “get_node” isn’t declared in the current class.

The Ship class in my code extends KinematicBody2D, and is not attached to any actual node in the scene tree (though for what I understand that shouldn’t be a problem). The Enemy script is sitting on a KinematicBody2D node in my scene.

I checked and found out that the problem is still there for methods other than just get_node (look_at doesn’t work either).

I’ve already tried restarting Godot in case it just didn’t update everything correctly but the problem is still there.

:bust_in_silhouette: Reply From: bnfgh

I managed to solve it. The problem was that the super class (the Ship class in my code) had an unsolved syntax error in it. Therefore, it didn’t save properly, and the subclass wasn’t able to acces it.

I’ll leave this here for anyone who might be dealing with the same sort of problem.