i cant declare a static variable in functions

Godot Version

Replace this line with your Godot version

Question

i want to declare a static var in functions like c++ but i dont find how to do it or if it possible in godot

for example

func doSomething():
static var lenght : int = 13 // this gives me error

Would be good to know the error the editor is throwing.

Anyways, a static var can be declared in the class scope, not function as far as I know.

You can find more in this documentation.

3 Likes

thank you for your reply