GDQuest / learn-gdscript

Learn Godot's GDScript programming language from zero, right in your browser, for free.
https://gdquest.github.io/learn-gdscript/
Other
2.04k stars 149 forks source link

20.2 Variable not defined #949

Open GiacomoCampioni opened 4 months ago

GiacomoCampioni commented 4 months ago

Solution requires calling an array variable called that is not defined anywhere before. Defining it inside the function prints out an error, even though the script functions the same.

Solution provided by GDQuest:

func run():
    combo = ["jab", "jab", "uppercut"]
    for action in combo:
        play_animation(action)

Alternative solution that does not get accepted:

func run():
    var combo = ["jab", "jab", "uppercut"]
    for action in combo:
        play_animation(action)