How to stop the given Flow state not using transitions?

Max Ivanchenko 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 4

For Example I have a behavior AI for a character. The Character have a State Machine and there lot of Flow states - activities. I just want to make the "Stop All Activity" feature. I don't know what flow is currently working, and don't want to do lot of transitions from every Activity states to one "Stop State"!

How to stop the given Flow state not using transitions? May be via code?


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

Using the Any State, you can listen to just a single transition that points towards your "Stopped" state.

Before transitioning, the Any State will exit any state it is directly connected to. So you can create dummy / empty transitions to each state you want to stop being active. 

(Note: In Bolt 2, this will be even simpler, because the Any State will exit any state it is directly or indirectly connected to, so dummy transitions wouldn't be needed.)

Thanks Lazlo! But is there any possibility to stop flow state via code?

Via C#? There is, in theory, but it's not simple and it's not guaranteed to stay that way across new versions. 

Another simple approach you could consider is to disable your state machine, which will exit all states. Then, change some variable on your object that would help the machine determine its new state from the start. Finally, re-enable the state machine. Does that make sense?