Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | XenonTrooper |
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 summon_char():
var NewSummon = self.SUMMON_RESOURCE.instance();
self.get_parent().add_child(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!
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?
klaas | 2020-07-23 17:52
That apparently seems to work, it’s pretty strange. Thanks!
XenonTrooper | 2020-07-25 00:26