-
Book Overview & Buying
-
Table Of Contents
Dynamic Story Scripting with the ink Scripting Language
By :
In programming, there are two approaches to accessing values in one system from another: polling and events-based. Either a value can be checked if it has changed (polling) or one system can wait for a message (event) from the other to signal that a value has changed. Because the second system must wait for an event to happen, this is often known as the observer pattern because the second system is observing events.
In the first section, we saw an example of polling in action. Each time a step of the quest came to its end, the Unity code checked (polled) the ink values to see if it should show a Button game object and allow the player to progress the quest. The second section moved us closer to an events-based approach, where the ObserveVariable() method was used within the Quest class. In the second project, whenever the end ink variable changed, it updated the End property of the Quest class in Unity. As this value (the End property)...