Skip to content

FSM Overrides and Outputs

Custom variables can also expose FSM template inputs and outputs.

Use VariableOverride when callers should pass a value into the FSM, and VariableOutput when the FSM should return a value back out.

This applies to both single-value variables and list variables.

FSM Overrides

Use VariableOverride when you want an FSM variable to be exposed as an input on an FSM template or reusable FSM setup.

This is the same pattern as built-in types such as FloatOverride:

using System;
using HutongGames.PlayMaker;

namespace MyNamespace
{
    [Serializable]
    [DataType(typeof(MyCustomType))]
    public class MyCustomOverride : VariableOverride<MyCustomType, MyCustomVariable, MyCustomVar>
    {
        public MyCustomOverride(IVariable variable) :
            base(variable)
        {
        }
    }
}

This lets PlayMaker treat the variable as something that can be overridden from outside the FSM, which is useful for template inputs such as:

  • target references passed into a template
  • configuration values like speed, health, or duration
  • custom data objects that should be supplied by the caller

List variables use the same pattern:

using System;
using System.Collections.Generic;
using HutongGames.PlayMaker;

namespace MyNamespace
{
    [Serializable]
    [DataType(typeof(MyCustomType))]
    public class MyCustomListOverride : VariableOverride<List<MyCustomType>, MyCustomListVariable, MyCustomListVar>
    {
        public MyCustomListOverride(IVariable variable) :
            base(variable)
        {
        }
    }
}

FSM Outputs

Use VariableOutput when you want an FSM variable to be exposed as an output on an FSM template or reusable FSM setup.

This is the same pattern as built-in types such as FloatOutput:

using System;
using HutongGames.PlayMaker;

namespace MyNamespace
{
    [Serializable]
    [DataType(typeof(MyCustomType))]
    public class MyCustomOutput : VariableOutput<MyCustomType, MyCustomVariable, MyCustomRef>
    {
        public MyCustomOutput(IVariable variable) :
            base(variable)
        {
        }
    }
}

This lets PlayMaker expose a writable output slot for your custom type so the caller can receive values from the FSM.

List variables can also be exposed as FSM outputs:

using System;
using System.Collections.Generic;
using HutongGames.PlayMaker;

namespace MyNamespace
{
    [Serializable]
    [DataType(typeof(MyCustomType))]
    public class MyCustomListOutput : VariableOutput<List<MyCustomType>, MyCustomListVariable, MyCustomListRef>
    {
        public MyCustomListOutput(IVariable variable) :
            base(variable)
        {
        }
    }
}

Tips

  • Keep the wrapper class names consistent so they are easy to recognize.
  • Add [Serializable] to every wrapper class.
  • Use the same [DataType(typeof(...))] on all related wrappers.
  • Start with a simple custom type and one test action before building larger editor workflows around it.