-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
[Proposal StateMachine] Add condition to transitions #19773
Comments
The thing is that it makes the state machine usable for logic. And from what I understood @reduz wanted to keep the system simple, and only for animation things (else people are going to need hierarchical FSM and all other extensions). From what I understand transitions should be triggered from code, there's no real need to make them into the state machine system itself. I don't say it's bad, but it might go in the worng direction regarding @reduz original idea. |
Well, the current state machine almost fits for what I need, it's all there, with a simple addition of conditions we can have more complex machines and IMO will be super cool to have this. At this moment, the machine only serves to very simple things, so simple that I almost see no advantage in it, it can be done by code. I think this simple change it's worth.
From my point of view, this is totally an animation thing.
I disagree, my first game prototype I was not using the state machine and it was very hard for me to control all this transitions, the movement logic was more complex because of this, when I've put all my animations on the state machine my problem was solved, my code now is much cleaner and simple. |
The state machine handles blending between two states. Obviously for simple 2D things without blending needed it makes little sense.
It's code inside the state machine editor, thus it is moving logic from script to the statemachine. Which makes this more than an animation only thing. Either we decide state machines should handle animation only or not, but adding this will definitely move more logic into the state machine, which i'm not sure is desired.
From what I understand, the statemachine here is not meant to replace the GDscript code. At least in the current design, both are needed. From what I understand it's only meant to deal with animation. So yeah, unless we are making state machines a more general purpose stuff (used for logic and all), your proposal just adds noise in something that, IMO, should be kept as simple as possible. |
But regarding to the substate machines / transition from any state, this can probably be implemented. |
I was bored and looked up the least updated issues. Isn't this kind of resolved by now? |
There is still one feature which would make the state machine easily controlable, currently you cant disable/enable different transitions by setting a condition |
@MunWolf wouldn't that just be part of the condition? |
Not really? |
@Riteo not everything is resolved. Items 1 and 2 will be fixed by the As I made a PR that after the merge closes this issue I didn't mind closing it after the |
Godot version:
8c7da84
OS/device including version:
Any
Issue description:
The current state machine doesn't have conditions for the transitions, so it is not possible to
control the transition of states from "environment" variables such as Unity or Unreal.
Unreal: https://docs.unrealengine.com/en-us/Engine/Animation/StateMachines/TransitionRules
Unity: https://docs.unity3d.com/Manual/StateMachineTransitions.html
My proposal is implemeting something simple, similar to the Unity.
Here is a prototype of what I was trying to do in godot:
The final version will be much bigger
Example of what I want to create in godot:
I've created my own state machine entirely on gdscript for my project and it looks like this:
And I expect that node "StateMachine" works in a similar way.
The benefits of this IMO are that "movement" code gets simpler because I don't have to worry about which animation I should play (and in my case, I have so many states that it's very difficult to work with it without a state machine) and it's more easy to debug (my current SM is a bunch of code and I need to use draw.io to help me visualize when I'm making the states/transitions).
So...
We'll need a way to specify variables when creating the state machine to later define these variables by code (like the example code above).
All transitions will need a condition that will use these variables that we define to control when you need to move to another state.
Real example of some transition condition to "Idle" state on my project:
is_on_floor and abs(lv.x) == 0
.I think it would be useful a way to see all conditions from incoming transitions just clicking in the state. Something like this:
Maybe transitions could be some kind of resource, that way, we can use the same condition several times. eg: Most of my states use the same condition when goes to "Idle".If item 3 could be implemented, We can just copy/paste the conditions.Right now, I can't select multiple states (useful to reorganize multiple states).
In my game, I've created some "shortcut" states (eg: "Any state", "All aims") just to simplify, I think maybe this could be done in godot using Sub State Machines but I can't test it without the conditions.
Something like this:
Example of Any State
Instead of this:
The text was updated successfully, but these errors were encountered: