Changing ink variables outside a story
Variables were first introduced in Chapter 4, Variables, Lists, and Functions. In ink, variables are created using the VAR
keyword and an initial value. Throughout a story, the value of a variable can be changed. By comparing their values, variables can also influence the flow of a story.
Variables are global in ink. Once created, they can be accessed by any other part of the code within the same story. This functionality is also carried over into a named property as part of the ink-Unity Integration plugin, called variablesState
. Every variable defined in an Ink story can be accessed by using its name.
In this topic, we will examine how to use this property to access and change values in a running ink story. We will begin by looking at how to use the variablesState
property and comparing values in ink to control its flow outside the story.
Accessing ink variables
The Story API in Unity provides access to ink variables. In this section...