0
Fixed

"Any State" node dies after disable/reenable

NeedsLoomis 9 months ago updated by Lazlo Bonin (Lead Developer) 3 weeks ago 9

It seems that when you disable then enable a game object, the state machine on it will jump back to start (expected), but the "any state" nodes in the same graph simply stop working.

Bolt Version:
1.4.1B5
Unity Version:
2018.3
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

Hi NeedLoomis,

So I'm not able to reproduce the issue when disabling/re-enabling a state machine. Any State seems to work. Do you have any more specific steps?

The issue I am seeing though is that a newly added Any State to an existing / listening graph won't work right away, which I can fix.

Hey Lazlo, here are my steps.  Worst case I can send the Repo! 

So I create an Embedded StateMachine.  The transitions are simple "OnEnter"s.




The FlowStates look like this inside:



I hit play and check/uncheck the gameobject a few times.  Notice that the "AnyState" only fires on Play and the very first Disable, but after that only the "Start" graph functions:

Fixed in Beta

Hi NeedsLoomis!

I see, thanks for the report. I'll have that fixed in the next beta along with a bunch of other fixes relating to state events.

I would point out that having On Enter State transitions from Any State doesn't make much sense, though. :P

Good to hear!

Thanks for the tip, what would be the easiest way to transition as soon as a state executes?

If knowing my use case helps, I tied Bolt into my messaging system.  I have nodes that will subscribe the StateMachine to a specific message, and nodes that will unsubscribe it.  I use the Any State so I can ensure that the graph can be unsubscribed no matter what the rest of it is currently doing (if it gets destroyed, for instance).  Since I cant place nodes directly in the AnyState, I just have it transition as soon as it activates.

That's a valid use case, but note that On Enter State / On Exit State will only be called once in Any State, not every time any other state is entered or exited in the graph. 

Another approach could be to have a second Start state that's not connected to anything, and therefore will always be active until the graph is stopped. Bolt fully supports multiple parallel active or start states.

Oh wow, I didn't know I could make multiple Start states, I see now that I can duplicate it!  Hoe does one normally add a start state?  I don't see it on the right click menu.

+1

Right click any state > Toggle Start State.