Is there a way to override variables and functions in inherited classes?
Override member variables and functions?
- Edited
- Best Answerset by trizZzle
trizZzle Variables: No. Functions: Yes.
https://docs.godotengine.org/en/latest/tutorials/scripting/gdscript/gdscript_basics.html#inheritance
Use super
to call the function from the super class:
func do_something -> void:
# pick one syntax or the other
super()
super.do_something()
Toxe Functions: Yes.
It doesn't seem to work for built-in classes, though, only for custom classes that you define.
If I try, I get an error such as this:
The method "get_var()" overrides a method from native class "FileAccess". This won't be called by the engine and may not work as expected. (Warning treated as error.)
DaveTheCoder True, you cannot override engine functions. Only the ones we write ourselves or virtual functions like _process()
.