GLOBAL VARIABLE ALTERNATIVES: HOW TO SHARE VARIABLES BETWEEN FSM MACHINES

STYLY supports Playmaker but unfortunately at the moment, playmaker global variables are not supported in STYLY at the moment. Global variables can be of great help and sharing variables are essential for creating complex logic.

Fortunately, we have a way around the global variable issue. We can use the Get FSM actions in FSM objects to get access to other FSM objects which have the variables we are interested in.

The flowcharts explain the concept of both the Global variables and our alternative

Now we will learn how we can do this in Playmaker. First, make 2 empty Game objects and name them FSM A and FSM B. This tutorial is just a proof of concept therefore it will be very basic. I have selected FSM A and added a FSM in it. I then create a variable called “Variable X” and select its type as float.

Then, select FSM B and add a FSM in it. Add the action “Get FSM Variable” to it.

Since “Get FSM variable” action needs a game object within FSM component in it to retrieve a variable, we pass FSM A object into the action.

In FSM B, create a variable with the same name and type so that we can access the value of variable from FSM A.

Now add variable X in store value.

Once this is done, whatever the value of Variable X is in FSM A, it will get duplicated into Variable X of FSM B. And that is how we can share variables. The type of variables range from INT to vector3. Different actions will get us different types of variables. For eg, we can get a Vector3 variable by using the “Get FSM Vector3” action.

Here’s a video tutorial to help you understand the concept.

To watch this tutorial in URDU/HINDI, please click here.