State machine bug: multiple active states

Miłosz Moczkowski 1 year ago updated by Lazlo Bonin (Lead Developer) 6 months ago 4

> It is an abstract machine that can be in exactly one of a finite number of states at any given time.

via wiki

Currently, it's possible to have multiple states running at the same time, meaning that Bolt doesn't really implement FSM. I usually run into this problem when transitioning from the Any State. It's a behavior that shouldn't be expected from a state machine. A workaround is to have dummy (empty) transitions between the Any and nested states, but it's ugly AF (see pic). Can we have this fixed please?

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Bolt 2

Not a bug, even in the basic Platformer Tutorial they want you having many active states in parallel. And it beats having to have multiple State Machines instead...

Just replace the Any State with an empty Idle State. Then whenever you've finished say Purchasing, transition back to Idle. (You can't do that with Any State anyways, hence the transition going in the wrong direction in the depicted. Then you can just rearrange the States so its not as ugly.

> Not a bug

If you call it a State Machine, then yes, it is a bug, because by definition State Machine can only have single state active.

Fixed (Unreleased)

Hi Milosz! It is indeed a very intentional design decision to allow for parallel states in Bolt's state machines. It greatly simplified some complex cases where you would otherwise have to have two or more game objects to run your logic.

Now, the Any State behaviour is indeed weird. It will only exit directly connected states before entering its destination state. That's obviously not ideal, and it is already fixed in Bolt 2 alphas (e.g. in Bolt 2, all recursively connected states are exited), but because this is a potentially compatibility-breaking change for existing graphs, we cannot port it back to a previous major version.