Skip to content

Conversation

Flavore669
Copy link

Hello!

I wanted to get your thoughts on a NestedFSM node I implemented. It derives from State and initializes a self-contained FSM that inherits values from the main FSM. Additionally I've also created a demo similar to the blacksmith demo to showcase this new functionality.

Looking ahead, I'm considering overloading the _on_enter, _on_process, and _on_exit functions to give users more control.
For example, in a fighting game, a "Crouching" nested FSM could use its _on_enter function to play the crouching animation. This ensures the animation plays before any sub-state (like "Crouch Jab") runs, eliminating the need to manually trigger it in every possible transition or every sub-state's on_enter function into the crouching posture.

Do you have any suggestions or concerns about this direction?

@ThePat02
Copy link
Owner

Yo! I already noticed you working on that. I will take a look later that week, as it is something I have been wanted to add for some time now, but the workaround of nesting a fsm inside a integrated behaviour tree was more comfortable (or less work).

Looking ahead, I'm considering overloading the _on_enter, _on_process, and _on_exit functions to give users more control.

What's the difference from overloading the state like you would normally? This is what you do with all states anyways, so I do not see why this would be a problem.

@ThePat02 ThePat02 self-requested a review August 26, 2025 08:52
@ThePat02 ThePat02 self-assigned this Aug 26, 2025
@Flavore669
Copy link
Author

Flavore669 commented Sep 4, 2025

I'm very glad to see you approve of this implementation! Hopefully I can get back to work on this now that I have more time on my hands. I plan to implement more robust transition checks for the Transition class. This would include generating warnings for cross-hierarchy transitions, such as when a nested FSM attempts to transition into an ancestor FSM.

Then after some clean up, comments, and a template I feel it should be finished.

@Flavore669
Copy link
Author

I'm just now realizing there is a lot more work than I thought to fully integrate NestedFSMs beyond adding configuration warnings for transitions into this plugin. I'm just going to continue working until I feel it's finished lol.

@Flavore669
Copy link
Author

Flavore669 commented Sep 7, 2025

Ok I think nested FSMs are in a good state.

  • Added script templates where appropriate
  • Added to the toolbox in the UI
  • Added to the documentation
  • Added a configuration warning to FSMTransition, that emits when a user selects a next transition state that is part of a outside of the FSM/NestedFSM's scope
    • The implementation is a bit shaky. I tried to keep it all self-contained in FSMTransition. I would like to see your feedback on it, perhaps I'm a bit paranoid.
  • Added a configuration warning to NestedFSM, that emits when a user selects an initial state that is part of a different FSM/NestedFSM.
    • This was also added to FiniteStateMachine. I feel it's not out of the question people would run state machines in parallel

Any feedback is welcome!

@ThePat02
Copy link
Owner

ThePat02 commented Sep 8, 2025

I will do some testing and experimenting! Thanks for your addition! Looks good so far!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants