Set/get bolt variables from script?

Basbo 4 years ago updated by JasonJonesLASM 4 years ago 4

Hey I used this writing scheme from another post, 

SceneVariables.current.Set("distanceFromPlayer", currentDistance);
then tried this from the API docs
Variables.Object(player).Set("distanceFromPlayer", currentDistance);
Bolt.SceneVariables.Object(komododragon).Set("distanceFromPlayer", currentDistance);

and finally this version:

self.GetComponent<Variables>().Set("distanceFromPlayer", currentDistance);

Well, none of these versions worked for me, got errors like

"error CS0117: `Bolt.SceneVariables' does not contain a definition for `Object'"

Does someone know the correct way for get/set the bolt variables or have I missed something?

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Satisfaction mark by Basbo 4 years ago

Hi Basbo!

I updated the API documentation on this, thanks for the heads up. You should use:









Hi that worked for my scene.variables and 


does the job with object variables on the same object, awesome!

Thanks for the fast feedback!


Hello. I could do with a little bit of a point in the right direction to get this one working please, it feels like I'm almost there, but am just missing something really obvious! I am trying to pass two variables from a C# script into Bolt.

I've got my script as follows, where I'm declaring and then setting the values for the two variables: FloorWidth and FloorHeight:

and I've tried to use the various code examples in the script as above to see if that worked, for example:

"Variables.Object(gameObject).Set("FloorWidth", 10)" and "Variables.Object(gameObject).Set(FloorWidth, 10)"

but I can't seem to get this working (worth a note though that I'm not that proficient at C#)

I refreshed the unit using Tools > Bolt > Update Unit Options

so that I could get access to the script in Bolt:

Which appears to work as I can see the two variables: FloorHeight and FloorWidth

And I've add got the two elements in Bolt as you can see on the left of flow:

But for whatever reason the values aren't passing through to Bolt. I'm making an assumption that I should be using the Get option and not the Set?

I've not got any values set in the Variables window:

I've tried with the variables in here and without them, but neither seems to work.

Really hoping that someone might be able to tell me where I'm going wrong?

Many thanks in advance for any help that anyone can give.

I think the issue is actually order of starts. Try adding a wait for end of frame right after the Bolt start unit to see. Might be assigning it, but not assigned yet when your actually getting it. You don't need to worry about bolt API here based on your script, unless you are assigning and adding the bolt variables manually through script.