kubecz3k / FiniteStateMachine

FSM plugin for Godot
MIT License
118 stars 22 forks source link

Manually enter a FSM state #24

Open salvob41 opened 6 years ago

salvob41 commented 6 years ago

Hello, I decided to open a new issue instead of going off-topic in #23.
What happen when I enter manually into a State if I am in another State? I try to explain it better:

Immagine we have the State of character with IDLE->WALKING->RUNNING->SUPERSPEED->EXHAUSTED. Imagine now that you can go to the state of DIE from any of those State (I don't know if this is realistic, but just imagine it is). If I manually enter in a state without any transition. What happens to the previous state? I suppose I cannot be in two states simultaneously, right? it means the exit method of the previous state will be called on entering the new state?

Hope it is clear enough. Thank you

kubecz3k commented 6 years ago

Yes you can change state from code from any point of your game (but dont do it directly inside enter() and exit() of another states) You just need to use fsm.setState(fsm.STATE.STATE_ID) method. Old state will exit normally and new one will normally enter() All the transitions and so on will work fine.