Handling Variables

v1.0

There are multiple ways to interact with Playmaker Variables that are set on the graph.

Copy Playmaker Variables To Global Blackboard

Add a CopyPlaymakerVariablesToGlobalBlackboard component to any object, and you can populate multiple Playmaker Fsm objects. Each of those will have it's Variables copied to the global ActionBlackboard, where any object can reference them.

Variables are stored as a structure that also includes the fsm and GameObject that holds the Variable.

Blackboard keys are stored as "GameObjectName/FsmName/VariableName" so that multiple Fsm graphs can have Variables copied.

public readonly struct PlaymakerVariableEntry
{
    public GameObject Source { get; }
    public PlayMakerFSM Fsm { get; }
    public object Value { get; }

    public bool TryGet<T>(out T value)
    {
        if (Value is T t) { value = t; return true; }
        value = default!;
        return false;
    }
}

Getting Values

To get the value back, you have multiple options.

Cache the Key

Directly from Blackboard

From a GameObject

From a Fsm

Setting Variables

You can also set variables on the Playmaker fsm.

Setting with Actions

The SetPlaymakerVariableAction and SetPlaymakerVariableFromBlackboardAction will let you set a specific value. There are also Actions for incrementing float and int values, or toggling a bool value.

Set Playmaker Variable Action

In this Action, you can populate the Target FSM. If you do not provide a Target FSM, one will be found on the component and cached for future use. You also set the Variable Name.

You must also set the Variable Type, and then provide the value you'd like to set of the correct type.

Set Playmaker Variable From Blackboard Action

In this Action, you choose to use the Executor Blackboard (local) or the Global Blackboard as source. You also choose whether the source is a Playmaker Variable that you've already cached.

If so, you provide the Source FSM, and the Key (variable name). If you do not provide a Source FSM, one will be found on the component and cached for future use.

You must also set the Target FSM and the Target Variable Name. If you do not provide a Target FSM, one will be found on the component and cached for future use.

Increment Playmaker Float / Int Action

Use IncrementPlaymakerFloatAction or IncrementPlaymakerIntAction to add or subtract value to an int or float Playmaker variable. If you do not provide a Target FSM, one will be found on the component and cached for future use.

Toggle Playmaker Bool Value

This action will toggle the value of a bool in the Playmaker variable list. If you do not provide a Target FSM, one will be found on the component and cached for future use.

Last updated