How do I use getVariableNumber?

I’d like to use getVariableNumber, not using getVariables.get(‘name’).getAsNumber();
But I don’t know how to do it.

Javascript programming has strict rules, it’s not possible to do as we imagine.

The good method is to use a variable like you do at line 1,2 and 3.
You can reduce runtimeScene.getVariables() in a variable too.
Like

let sceneVariables = runtimeScene.getVariables();

1 Like

The good method is indeed to use getAsNumber(); and as Bouh said you can keep a reference on the scene variable to reduce the line lengths.

Any other method is not officially supported and will break your game in a future version of GDevelop if you use it - stick with getAsNumber() :slight_smile:

1 Like