0
Answered

Statemachine - activate only one child

Christian Engler 3 years ago updated 3 years ago 2

Coming from a another dev world and statemachine workflow, i have a question concerning the bolt statemachine.

problem: i try to bind states to UI panels in order to activate them. it seems rather tedious to set panels active and at the same time any other panel inactive. 

temporary solution: i have a statemachine were each state sets one scene variable to the state/panel name. in addition, i have a flow machine, constantly checking the scene variable for a hit (panel name) and then activate the panel accordingly.

question: is there a way to test a list of strings and make decisions based on that. something like 

foreach(var item in stringlist)
{

 switch (item)
{
case 1:
Console.WriteLine("Case 1");
break;
case 2:
Console.WriteLine("Case 2");
break;
default:
Console.WriteLine("Default case");
break;
}}


Cheers
Chris


 

Bolt Version:
1.4
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
+1
Answered

Hi Christian,

Sure, the equivalent of C#'s switch in Bolt is either a Switch (branches the flow) or a Select (chooses a value). You can configure the cases through the Graph Inspector. In that case, Switch/Select on String:

thank you, looking good. :)

next question is coming.