Skip to content

Variables

Actions can use variables instead of constant values.

PlayMaker defines variable types for the equivalent data type.

Example

Let's use float as an example:

Float

public float MyFloat;

This creates a normal float field.

FloatVar

public FloatVar MyFloatVar;

This creates a float variable field that can use a constant float value or reference a float variable.

FloatRef

public FloatRef MyFloatRef;

This creates a dropdown to select a float variable.

This is often combined with a WriteOnlyAttribute for action outputs:

[WriteOnly]
public FloatRef Result;

Value Property

Actions can access Var and Ref values using the Value property:

var health = HealthVar.Value;
HealthVar.Value += 10;

Enum Variables

Enum variables need a BaseTypeAttribute to define the exact type of enum to use:

[BaseType(typeof(LightType))]
public EnumVar LightType;

The action should cast the enum value to the required type:

Light.Value.type = (LightType) SetType.Value;

Attributes

Action parameters can be customized using attributes.

These are some of the more common attributes:

Tooltip Attribute

The Tooltip to use in tooltips:

[Tooltip("The light to turn on.")]
private LightVar Light;

DefaultValue Attribute

The DefaultValue for the parameter used when creating and resetting the action.

[DefaultValue(10)]
private FloatVar Speed;

OwnerDefaultValue Attribute

OwnerDefaultValue marks a parameter as defaulting to Owner.

Note: There is also a rule that the first parameter is automatically considered OwnerDefault if it is a Component. Use NotOwnerDefaultValue to override this rule.

MatchType Attribute

MatchType indicates that a parameter should match the type of another parameter: