0 votes

Note: I also asked this question over at the Godot Forums.

I created a scene for my (2D) game which is a subclass of Sprite. Essentially it's Sprite, with a script added that makes it draggable during play, and emits a signal when it's being dragged (which is used to update a label that shows range to a stationary object on the map). Another object, basically a graphical menu, allows the player to create an instance of this subclass of Sprite, which can then be dragged to a selected location.

Now, the game should have multiple objects with similar behavior (draggable, range displayed by that same label) but not identical. I'd like to subclass this one and then change the things that should be different by overriding methods and properties of Barricade (the first class). Is there provision in Godot to subclass a user-created subclass of one of the built-in classes? Obviously I could just copy the class and change the properties/methods, but then if I tweak the script it becomes a nightmare to update all the copies.


asked Jul 12, 2019 in Engine by CarlF (12 points)

1 Answer

0 votes

Here's a video the might help!
Watch this video Instancing Scenes to a single scene it does what you exactly said and plus its organize-able. Read more about this here.

answered Jul 12, 2019 by Dooowy. (214 points)

Thanks for the quick answer, @Dooowy. I know how to instance. As I mentioned, there's a menu in my game that lets the player create instances of Barricade. What I want is a subclass, not an instance of a class.

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.