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.
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.