Variables
State Machine and Runner Variables
State Machine 2 introduces two types of variables that integrate with Game Creator 2's visual scripting system.
All variables can be created from the State Machine Asset, State Machine Runner, or the Blackboard in the Graph Editor.
Variable Types
State Machine Variables
Asset-level (global)
Shared state across all runners
Runner Variables
Instance-level (per runner)
Unique state per GameObject
State Machine Variables
These variables are stored in the State Machine Asset itself. All runners using the same asset share these values.

Use Cases
Global game settings
Shared configuration values
Default values for all instances
Behavior
Changes affect all runners using the asset
Values persist between play sessions (stored in asset)
Reset when asset is reimported
Be careful when modifying State Machine Variables during runtime - changes will affect all active runners.
State Machine Runner Variables
These variables are instance-specific. Each runner maintains its own copy with independent values.

Use Cases
Character-specific state (health, mana, ammo)
Individual object behavior
Per-instance configuration
Behavior
Each runner has independent values
Values are initialized from the State Machine Asset
Changes don't affect other runners
Creating Variables
From the Blackboard
Open the Graph Editor
Click + in the Blackboard panel
Choose the variable type
Name your variable
From the Inspector
Select the State Machine Asset or Runner
Expand the Variables section
Click Add Variable
Configure the variable type and name
Supported Types
Bool
True/false values
Integer
Whole numbers
Float
Decimal numbers
String
Text values
Color
RGBA color values
Vector2
2D coordinates
Vector3
3D coordinates/positions
GameObject
Reference to a GameObject
Sprite
Reference to a Sprite
Texture
Reference to a Texture
Material
Reference to a Material
Animation Clip
Reference to an Animation Clip
Audio Clip
Reference to an Audio Clip
Game Object List
List of GameObjects
Using Variables in Nodes
Variables can be accessed directly in node properties:
Click on a property field
Select Variables → State Machine or Variables → Runner
Choose the variable
Accessing Variables via Visual Scripting
Use the Properties system to read and write variables from any Game Creator 2 instruction or condition.
Network Synchronization
When using multiplayer modules (Fusion or Photon):
Select a variable in the Blackboard
Enable Network Sync
The variable value syncs across all clients
Best Practices
Use Runner Variables for Gameplay
Most gameplay values should be Runner Variables:
Health, mana, stamina
Inventory counts
Quest progress
Character state
Use Asset Variables for Defaults
Asset Variables work well for:
Default configuration
Shared constants
Initial values (copied to runners)
Name Consistently
Use clear, descriptive names:
PlayerHealth(good)h(bad)EnemyChaseSpeed(good)speed(ambiguous)
Last updated
Was this helpful?