question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Abstract parent classes need to be registered to godot.

See original GitHub issue

Do not know if it is a feature or a bug.

I have this class:

import godot.annotation.RegisterClass
import godot.annotation.RegisterFunction
import godot.global.GD

@RegisterClass("Player")
class Player: BaseEntity() {
    @RegisterFunction
    override fun _ready(){
        GD.print("I am the player!")
    }
}

If BaseClass is not registered to godot (should not be, as it is an abstract class), then the generated code will reference the non-existant BaseEntityRegistrar. This is also bad, as because that parent is abstract, the generated code is now wrong, as it tries to get its constructor.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
chippmanncommented, Oct 30, 2022

I wouldn’t use _ready for the workaround. The engine will call this method if it’s registered. Use a method name of your own to minimize call overhead.

0reactions
Frontridercommented, Oct 30, 2022

As a workaround you can just export an empty dummy funtion in the base class. I’ll fix this asap

Yap, adding a registered “_ready” method to the base class fixes it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does GDScript have Interfaces and/ or abstract classes?
I suppose you need interfaces/abstract classes for organizing complexity and type enforcement. As @eska well mentioned, GDScript is made with ...
Read more >
Abstract Classes - Godot Kotlin/JVM
You can define a abstract class and register it's members the same way as you do for normal classes. Under the hood, we...
Read more >
How to properly abstract in GDScript? : r/godot - Reddit
I tried the Inherited Scene and detach the base script, add a new one and extend the base class, but that doesnt seem...
Read more >
Custom Nodes in Godot 3.1: Class Name Keyword (tutorial)
You can register a GDScript file as a type in your entire project in Godot 3.1 with the class_name keyword. Learn how in...
Read more >
Refactoring the Pong Game | Pong GDScript Basics | Ep 07
Refactoring our Pong Game. In this article I want to go over the following things: Truth of coding; Refactoring; Code Smells; Extract &...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found