New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaced StateTransitionSO with TransitionTableSO + Editor #114
Replaced StateTransitionSO with TransitionTableSO + Editor #114
Conversation
Created TransitionTableEditor and StateEditor. - TransitionTableEditor allows you to fully configure the transition table in an easy way. - A list of the states in the table is displayed, with the initial state at the top. - States can be sorted manually to change the initial state or just for ordering. - The order of the states bellow the initial shouldn't affect the behaviour of the state machine. - Added buttons to easily switch back and forth between state editor and transition table editor. - The state editor is a simple reorderable list with all the action in the state. - Clicking on a state will display all of its transitions, along with their conditions. - Transitions can be sorted to change the order in which checks are executed. - Transitions can be removed. - Conditions can be easily added, removed and sorted through reorderable lists. - New transitions can be added with the + button underneath the states list.
|
This looks neat man. This weekend I will dive in into the code! |
Thanks! Editor code might be a little messy because I was learning on the fly, I'm gonna try to clean it up, but do check it out and tell me your thoughts! |
…-tables # Conflicts: # UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/BeginJumpDescent.asset # UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateTransitionSO.cs
|
I merged it into a new branch |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.



Generic State Machine
I've replaced StateTransitionSO workflow with a TransitionTableSO workflow. In the TransitionTableSO we list all the possible transitions of a StateMachine and feed that into the SM instead of the initial StateSO. The initial state is now the first "FromState" in the transition table.
Having the transitions decoupled from the states allows for different setups without having to duplicate states just because one transition is different. And having the transitions in a single SO allows for easy reusability.
The decoupling is only present in the editor. At runtime, the states still hold their own transitions and have them fed from the transition table during initialization. We could decouple the runtime as well by having the SM handle the transitions, but it wouldn't really change anything. Rather, it'd add an extra bit of overhead because it'd rely on lookups.
I've set up the transition table for the main character and it seems to be working just as before. Do test, though, and let me know if you spot anything.
Credit to @kcastagnini since the idea comes from his FSM implementation.
I've added a complete editor for the transition table for easier usage.

Patch notes:
Created TransitionTableEditor and StateEditor.