Skip to content

Variables

A variable has a name, a type and a scope, which sets where it lives:

Scope Where it’s defined Lifetime
Global The Variables tab of the Narramancer window One value for the whole game
Scene A Narramancer Scene component While that scene is loaded
Verb A verb’s own inputs and outputs While that verb runs

Every variable is saved with the game. A variable has to be defined before the game runs, with a type and a unique name.

Open the Narramancer window, switch to the Variables tab, and add variables to the list.

The Variables tab of the Narramancer window.

The third column is the starting value, for the types that support one. The variable takes this value when the game starts.

Read a variable with a Get Variable node and write one with a Set Variable node. Set the node’s scope to match the variable.

A Set Variable node writing the global variable ‘money’.

Set Variable only works inside an ActionVerb, and only changes the value when it runs.

A Get Variable node reading the global variable ‘money’.

Global variables can have a starting value in the Narramancer window, but that window can’t point at objects in a scene. To give a verb a scene object, use one of these three:

  1. A Set Global Variables component, which assigns global variables when the scene starts.
  2. A Narramancer Scene component, with the object assigned to one of its scene variables.
  3. A Run Action Verb component, with the object assigned to one of the verb’s inputs.

All three are under GameObject → Narramancer. After changing a verb’s inputs or the global variables, press Update Assignments on a Run Action Verb or Set Global Variables component to sync it. Values assigned to a renamed input or variable are kept, as long as its type is unchanged.

Under the hood, each running verb and each noun instance also has a blackboard: a set of values stored by string key. The Get Blackboard Variable and Set Blackboard Variable nodes read and write them directly. Most games never need to. Variables and flags cover the same ground without string keys.

Narramancer is source-available. It's free for noncommercial use underPolyForm Noncommercial 1.0.0, and commercial use needs an Asset Store license.Source on GitHub.