Getting or Setting Bolt Variables from C# Scripts – Unity3D Bolt Micro-Tutorial

This entry is part of a series of tips I am creating as I make my game.

You can use Bolt for free by downloading it from the Asset Store.


What we need: Access to Bolt variables from a C# script, either getting or setting them.

Input: Depends on the Bolt variable, but we will need to include the Bolt/Ludiq namespaces (i.e. ‘using Bolt;’) and if accessing the variables from a specific GameObject we will need a reference to that game object.

Output: A result, either the value of the variable if we ‘Get’ it, or the value stored when we ‘Set’ it.

How this saves you time: This tutorial will get you started in the right direction for setting up interfaces between your C# scripts and any Bolt Flows/State Machines.

Summary: Often times there are 3rd Party assets, existing scripts, or other sources of C# scripts that would take too much time to ‘re-implement’ in Bolt. However, we still need to integrate these scripts into Flow/State Machines. We can use the Bolt API to do this.


Variables set from a C# script, not from Bolt itself. This can be very useful for integrating non-Bolt assets into your project.

In the images above, you can clearly see Skeleton_21‘s health being accessed despite it being a Bolt Variable.

How to Implement

First ensure the API is available.

Second, setup the references to GameObjects that contain the Flow / State Machine’s / Variables you want to manipulate:

Or if you are accessing Application / Scene variables, directly reference them (no GameObject needed):

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: