0 votes

Hello!

I'm starting a project and decided to go ahead and use GDScript. I'm new to the engine and I encountered a problem with the function get_parent(). I checked in the documentation and it is a function of Node, which my class extends.

extends CardBase

class_name CardSummon

const SUMMON_RESOURCE = preload("res://src/Scene/Summon.tscn");

func summonchar():
var NewSummon = self.SUMMON
RESOURCE.instance();
self.getparent().addchild(NewSummon);

(Note: CardBase extends Node2D and therefore Node)

The error I got was: "error(9, 1): The method "get_parent" isn't declared in the current class. I don't see how this could be the case, so I'm hoping for some helpful input.

Thanks in advance!

asked Jul 23 in Engine by XenonTrooper (12 points)

Sometimes godot has problems with multiple extensions of classes. I think is some kind of class caching problem.
I my case shutting down and restart godot and open and save the classes does solved the problem.
Have you tried this?

That apparently seems to work, it's pretty strange. Thanks!

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.