Finite State Machine "Helper" Behavior

Hello all,

Recently there has been a lot of new interest in Finite State Machines (FSMs) and GDevelop. From new tutorial projects coming out to people posting great threads around it.

Very short version/high level request: We need a way for a player to add a list of state names to an object, and a condition to check for those statenames, as well as an action to change the current state the object is in.

Long version:

I wanted to make an extension to help make FSMs easier for newer users. The idea:

  • User adds a “Finite State Machine Helper” behavior to their object.
  • Within the behavior settings, the user can define however many states they want for that object.
    • e.g. “idle” “running” “jumping” “attacking” “jumpAttack” etc
  • A new condition and new action would be available.
    • “ObjectName is currently in Statename” condition and “Change current state of ObjectName to Statename” action.

Overall, pretty simple, right? All it’s doing is assigning an object variable (currentState) and populating it/checking for it based on the conditions/events. The big goal was to help users new to FSMs to better visualize and track their possible states.

The problem: As far as I can tell from the Behavior Extensions editors, there is no way for me to make property values be “options” in the event editors for the users.

If you think about the expression builder, if you’re trying to select an Object’s variables, it shows every possible variable available. This is similarly true for the behavior parameters or properties, but because it displays the parameter/property name, and not the value, all the user would see is “Property1, Property2, etc”.

So while I can absolutely create the behavior properties of GameState 1/2/3/4-20, and populate them on an Exampleobject, the user is only ever going to see “Change the State of ExampleObject to GameState 2” which eliminates any efficiency/easy of use gains.

Is there any way to accomodate this type of capability in extensions? or is this something that can be added to objects? (Maybe instead of behavior, there’s just a “States” tab and that condition/action be added?)

Overall this isn’t perfect. A perfect solution would be full visualization/flow of FSMs, but this is would be a great way to make learning how to use FSMs easier.


The simpliest to do is to allow the user to write himself the name of the state in an action for initialize them.
Or give a list of states in the behavior properties, separate by a comma and handle this in js and the js will generate the structure variable with these states… but it’s roots and a bit ugly in term of UX i agree.

  • For the option list in the parameters behavior i would see this choice too :3

  • For replace the list you can allow the user to write himself the value in plain text, like users can do in my gamepad extension with the input key.

Even with the expression builder or with the autocompletion of variables, if you want see the name of states with your custom instructions it’s not possible either, because there is not yet the variables choice as parameters for the extensions, i would see this too!

For finish about the FSM, FSM use states, and states are just simple variables.

Maybe an user can see this extension easier to use, but in background it’s just an variable for a state, for me add this kind of extension will make user dumb because the reflexion for create the system is the basic of any games, the variables, if an user is unable to create and use an variables good luck for the future of her game.

I don’t disagree that this is simply setting, checking, and using an object variable.

I think the main thing this would gain/provide is make the possibility of error smaller. By allowing for a selection list of states the user defined earlier, there’s less risk of someone typing “Runnig” when they mean “Running”.

But yes, it’s mainly meant as a “helper” for stuff like this, much like the Health and Fire Bullet extensions do.