Trigger/Gimmick
Trigger/Gimmick overview
Trigger/Gimmick is a system that easily configures interactions within a space. It is used by configuring Unity components.
There are items, players, and more within the space, and various events occur, such as collisions due to physics or player actions. In response, feedback is provided to the player, such as playing sounds or changing appearances. This is the basic structure of interaction.
The Trigger detects events occurring in the space or player actions and writes to the specified parameter. The Gimmick modifies the space or players based on the parameters. By linking these together, you can create interactions.
State
Items and players have parameters that can be accessed by triggers and gimmicks. Each of these parameters is called a state.
An item can have multiple states, which are distinguished by a string called a key. The space instance itself also holds states, called global states.
To summarize, the space instance contains the following types of states:
- Item states: identified by item + key
- Player states: identified by player + key
- Global states: identified by key
States between different items and players are independent, and even with the same key, they refer to different states.
Triggers specify the state to write to, and gimmicks specify the state to read from. The values held by states are classified as scalars, vectors, or signals, with further detailed classifications within those. These classifications are called state types.
- Scalars: Bool, Integer, Float
- Bool: a value that can be expressed in two states, such as on/off (e.g., true)
- Integer: a value that can be expressed as an integer (e.g., -4)
- Float: a value that can be expressed as a real number (e.g., 1.234)
- Vectors: Vector2, Vector3
- Vector2: a two-dimensional real number vector
- Vector3: a three-dimensional real number vector
- Signals: represents the occurrence timing of single events, such as being interacted with or grabbed
The type must match when reading from and writing to a state.
Vectors can also be read and written as multiple floats. When the key for writing to a vector is “key”, each element of the vector can be read and written with keys like “key.x”, “key.y”, and “key.z”.
Operation
Interactions that react immediately to something happening can be created using just triggers and gimmicks.
However, in more complex cases like the following, an additional mechanism is required:
- When a trigger detects something, and a gimmick performs an action after a certain period of time
- Combining information from multiple triggers to determine and change what the gimmick does
- Counting the number of detections
To describe these more complex interactions, you can use Operation.
Operations read states, perform some processing, and then write to states. Operations do not directly detect or modify the state of the space, so they are used in combination with triggers and gimmicks.