Static Functions
A static function is a member function of a class that can be called even when an object has not been initialized.
A static class cannot access any variables of its class except for static variables.
Godot GDSCript does not have static variables.
You do not need to create a class instance to use a static function.
It’s best to use static functions when you don’t depend on any class members (variables).
# Animal Class
extends Node2D
class_name Animal
static func printHi() -> void:
print("Hello!")
# Another Class
extends Node2D
# Inside of some function
_ready():
# You do not need to instantiate the animal class in order to use printHi()
Animal.printHi() # prints "Hello" to console
Resources
Github Project:
Godot Tutorials Resources