-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Added a few new features for FSMs #75
base: main
Are you sure you want to change the base?
Conversation
I had a use case where I had booleans, always causing a transition from a given state, but to different paths. Before, I had to create two separate transitions, but now I can create a transition where I assign two next states, one on true and one on false, based on a function written in an extended script.
Hello! First of all: Thank you for contributing to this plugin. I will review your changes in the next few days, when I got a little more time on my hand! Just some quick notes:
One thing to keep in mind. We will soon merge #73 by @SirPigeonz that will allow users to swap around nodes freely inside Behaviour Patterns freely. We will need to see if there are any breaking changes! |
Sounds good! Once you review it, if you'd like to move the print and always to flags, I can see about making those changes! This was just the path that was most obvious to me at the time. I will say, as I look at adding a flag for "always transition" to Thanks about Split! I chose this path because it required no external changes outside of my class. I didn't have to modify the state machine or anything else, it just works as-is (if you use it correctly). That said, it not being a subclass of I'll hang tight on this one until after #73 comes in and then I'll work with you on figuring things out! Also thank you so much for this plugin. It's great functionality, reasonably well documented (which is why I chose it over alternatives), and feels like it has a lot of polish. |
Alright, I've investigated how to conditionally modify Inspector variables (via |
I am not quite sure. One thing I thought of tho: Having the Split note being some sort of composite node instead of a transition.
But I'm not at my PC right now, so... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed before, having an always_transition
property bool on FSMTransition
would be a better idea. This should be checked in the FiniteStateMachine
class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sketched this out locally, and ended up implementing a new property (with some dependency juggling with event
and use_event
) and just replaced is_valid()
:
## Evaluates true, if the transition conditions are met.
func is_valid(_actor: Node, _blackboard: Blackboard) -> bool:
if always_transition:
return true
return false
This would keep everything else in place, because FiniteStateMachine
fundamentally doesn't need to change -- it's just the transition itself that acts differently. Do you seen an advantage to exposing this logic to the FiniteStateMachine
class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this to show what I mean. If you'd like the implementation to change a bit it'll be easier now that it's in Transition
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A own print state node is overkill - however this feature should totally be part of a debugging toolset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved it into examples and removed class_name
.
That might be a bit of an overkill :D and harder to use. |
I'm interested in what you see as the advantage to this direction, so I can try and understand it. One of my goals was to reduce the number of transitions I'd need to write for dead-simple boolean checks that lead in two different directions. This wouldn't exactly achieve that goal. |
Love the idea! :D
I like it. Although, Pat doesn't like many nodes. I have a node like this already in my project tho, xD I will steal your icon! xD (I was too lazy to make one yet)
I agree this should be part of debug tools, not a separate state. I planned to add signals for basic nodes events like tick() and on_enter(), on_update(), but didn't have time lately. Those could be used for debug as well. For example, you could just make a node that you add as a child of the state node and it will handle the printing ba connecting to on_enter signal. Cool addition thx for the PR! :) |
Well, I think stuff like "always" can be simply included in the base node. |
I agree, but I have a "but". If you add too many features in the base class when you DO want to extend the class, you have to handle all those features in the child classes even if they don't need some features. For example, |
Agreed. I'm already experiencing it with the "next" transition member when I have a split transition, and having incompatible modes (like "always" in "split" when that simply can't work) can lead to confusing code. |
I was working some with the FSM capabilities and wanted to add some additional functionality. The three core things added here:
LeafPrint
for BT, just prints some text on enter.Of course feel free to reject this based on not wanting these particular features in here, or let me know if there's anything else you'd like to see changed so it fits better. I just figured if I was doing some of this work for myself, might as well pay it forward!
I think I covered all the bases here as well.