Extending Godot base classes like Vector2

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hamoom

Does Godot allow you to extend base classes?

can I write code for something like

Vector2.random_angle()

:bust_in_silhouette: Reply From: kidscancode

No, you can’t extend a base class.

An option: you could define some static functions in a singleton.

static func vector_random_angle(vector):
    return vector.rotated(rand_range(0, 2*PI))