-
-
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
Redesign feature request: Simplify transitions #58
Comments
Hey! I get what you are trying to say. Behaviours can become REALLY complex very fast, but there are some ways to optimize your stay machine.
Regarding your possible solutions:
I don't think this solutions fits into the whole node based approach of the plugin. Yes, trees will get messy and big, but that's just FSMs and BTs for you. For more complex behaviours, I always suggest keeping your machines in their own scene, so you can reuse them aswell. Something like
I am not sure, if I am understanding this correctly? Right now you can trigger a transition in 3 ways.
Could you maybe give an example on how your idea would work and what it would change? |
Exactly. The problem is you have to choose one of three ways. And each way has some limitations.
This way lacks customization
This way needs too much nodes in simple constructions. For example if you want to have basic transition from one state to another you must have My idea here is to make transition nodes more "optional". ## Changes the current state and calls the appropriate methods like _on_exit and _on_enter.
func change_state(state: FSMState) -> void:
# Exit the current state
active_state._on_exit(actor, blackboard)
+ for child in active_state.get_children():
+ if child.next_state == state:
+ child._on_transition()
+ break
# Change the current state
active_state = state
# Enter the new state
active_state._on_enter(actor, blackboard)
# Emit the state changed signal
emit_signal("state_changed", active_state) |
Idea here is to connect |
I see what you mean. Let me think about these changes and I'll give you some feedback tomorrow. Generally I don't consider many nodes a problem, because the whole plugin is designed around the idea of state machines having actual componenst you can drag around instead of abstract transitions in code, but adding more functionality can't hurt. As said, I'll try some things out and get back to you! |
I ended up writing a make shift plugin to edit the transitions as a table. Makes it easier to get a bird's eye view of the machine when you have a lot of states and events. |
If this is in a usable state (or even a good starting point), feel free to open a PR draft or something :) |
Done |
Problem description
So I have a pretty simple FSM with 4 states: Idle, Walk, FollowUntil (follow enemy until it's not in attack range), Attack.
I want to have an opportunity to make transitions almost from every state to every other state. And sometimes I want to configure some transition using scripts. But it turns out I have to make 4 (states amount) * 3 (other states amount) = 12 transitions. Looks pretty bad... And I have to make even more when I make new states. And it turns out we have geometry progression of transitions...
Yes, I know we can call
switch_state()
on FSM to switch states. But it makes transitions uncustomizable. And mixingswitch_state()
and events are kinda bad decisionPossible solutions
Remove transitions
First thing that comes to mind is to remove transitions at all and make function like
_handle_transition(to_state: String)
in FSMState template. So you can process needed transitions using codeSmart solution - notify transitions during
switch_state()
Ok. So the problem is "I want to change states from one to another and also have opportunity to customize some transitions". To solve this we can make
switch_state()
the desired way to change states instead offire_event()
. And inswitch_state()
function we will seek for child transition that satisfies our logic and call_on_transition()
of this node if foundThe text was updated successfully, but these errors were encountered: