You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public enum GenericState
{
Idle,
Run,
Jump
}
public enum Trigger
{
Fire,
Release
}
var sm = Fsm<GenericState, Trigger>.Builder(GenericState.Idle)
.State(GenericState.Idle).TransitionTo(GenericState.Run).On(Trigger.Fire)
.State(GenericState.Run).OnEnter(changeArgs => { Console.WriteLine("Entering run state"); })
.TransitionTo(GenericState.Run).On(Trigger.Fire)
.Build();
sm.Trigger(Trigger.Fire);
sm.Trigger(Trigger.Fire);
What I wish is that the state machine would be able to enter a state even though the target state is already the current state, and that the OnEnter method would run, which is not what happening here, as only one 'Entering run state' is being printed.
This is a very useful feature as it can simply reuse code for some state machines where there is simply a need for a reentering state. I encountered it myself: I have a character that is running based on mouse input, and when there is new mouse input and the character is already running, it needs to run again but towards the new mouse location, thereby requiring the OnEnter code to run again.
The text was updated successfully, but these errors were encountered:
I have this very simple code:
What I wish is that the state machine would be able to enter a state even though the target state is already the current state, and that the OnEnter method would run, which is not what happening here, as only one 'Entering run state' is being printed.
This is a very useful feature as it can simply reuse code for some state machines where there is simply a need for a reentering state. I encountered it myself: I have a character that is running based on mouse input, and when there is new mouse input and the character is already running, it needs to run again but towards the new mouse location, thereby requiring the OnEnter code to run again.
The text was updated successfully, but these errors were encountered: