Forums › 💬 NodeCanvas › ⚙️ Support › [Bug] FSM doesn't start on when start node is linked only from "ANY STATE" note › Reply To: [Bug] FSM doesn't start on when start node is linked only from "ANY STATE" note
Hello there,
Just to clarify, please note that the normal behavior is that the FSM will STOP if the FSM ends up on a Finished State without any outgoing Transitions AND there are also no other “Running” nodes like an AnyState or a ConcurrentState.
With that said you’ve come across quite an edge case here in regards to order of execution. I’ve just fixed this for the next version. To fix this on your end meanwhile, please open up FSM.cs and change the contents of methods OnGraphUpdate to be like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
protected override void OnGraphUpdate() { if ( currentState != null ) { //Update defer updatables (basically AnyStates and ConcurentStates) for ( var i = 0; i < updatableNodes.Count; i++ ) { updatableNodes[i].Update(); } //Update current state currentState.Update(); if ( onStateUpdate != null && currentState.status == Status.Running ) { onStateUpdate(currentState); } //state has nowhere to go.. if ( currentState.status != Status.Running && currentState.outConnections.Count == 0 ) { //...but we have a stacked state -> pop return to it if ( stateStack.Count > 0 ) { var popState = stateStack.Pop(); EnterState(popState, TransitionCallMode.Normal); return; } //...and no updatables -> stop if ( !updatableNodes.Any(n => n.status == Status.Running) ) { Stop(true); return; } } } //if null state, stop. if ( currentState == null ) { Stop(false); return; } } |
Please let me know if that works for you.
Thank you.