The issue with GDevelop functions is that the variable has to exist IN the function too. You can’t just access whatever variable you want unless the function knows that it exists
IMO, this is very unintuitive, especially compared to Construct 3’s functions, which just let you use any variable anywhere
Scene variables have to be declared before they can be used. Fair enough I guess? But why global variables? Aren’t they available for the WHOLE project? Why not my functions too?
Also, it’s inconsistent. Or at least it feels like it
For example: Change the variable state of player = "fall"
This object variable is not declared in the function, and it still works
Change the gravity of player = 1200
This IS declared in the function:
Now, I get why it’s designed this way for custom behaviors and prefabs, since they’re meant to be shareable, but functions are typically used exclusively in the project they’re built in, so like, I don’t understand why it has the same limitations
Is it possible to make the functions a little more flexible and intuitive?
When it comes to variables though. I think the preferred method is to pass the variable to the function as a parameter (when possible). You can then return values back to the variable or create an expression instead and return values through it.
As of this post, you can still access variables external to the functions. It’s literally in the event conditions and actions list as ‘external variables’
I have done my best to explain why global variables should be global including for project-specific functions and extensions (they should never be acceptable for submitted extensions/objects as they can’t maintain that structure, but that’s an entirely separate conversation than internal project-specific items), including that is how global variables work in most programming languages (including javascript). The dialogue is ongoing, but in the interim you should still be able to use these conditions and expressions as needed.