AXEL Demo File - Jane Veeder, SFSU

Parameter Decay Over Time Using Arrow Keys (demo for Virtual Pet - Mobile Project)

(c) 2004 Jane Veeder, SFSU

Interaction: User controls 3 parameters affecting the Apple using the Left and Right arrow keys. Each press increments (increases by steps) the parameter. All the user can do is INCREASE the parameter, the authored interaction does the rest.

Following a 2-second delay after the last arrow-click for any given parameter, the parameter value starts reversing, decreasing or "decaying" over time. The parameter value decreases or decays over time until its specified minimum value has been reached, then the decrease reaction is deactivated. You could also set up a maximum value that could be tested for. When the user once again presses the arrow key, the decay is interrupted and the user parameter is incrementally increased.

Here are the key components of how this works:

Note that there are a variety of ways to design for this functionality. You can set up a separate set of these components for EACH parameter the user controls and have them operate and be displayed separately. You can also combine two or more of the controllable parameters into one or two channels of displayed results.

a) The User Parameter (the parameter the user increments (more, more, more)). This parameter controls what the user sees as the results of their actions in pressing the arrow keys. The connection may be direct, e.g. when the parameter is controlling scale (bigger, bigger, bigger), or indirect, e.g. when the parameter is controlling which of N versions of an object is being swapped in using SwitchGeometry reactions or which of N materials are being swapped in using SwitchMaterial reactions. If the connection is indirect, you will need to use a custom or ParameterRange sensors to read the User Parameter and then trigger reactions as appropriate (see "e." below). This demo shows both direct (the apple's scale) and indirect (it's color) methods.

b) The “Decay” Reaction , a reaction that decreases the User Parameter by steady amounts over time. The Decay Reaction is triggered continuously at regular intervals by a TimePulse Sensor. This reaction is activated or deactivated by the Custom Sensor depending on the status of the User Parameter (has the minimum value been reached?) and the Switch Variable (is it ON or OFF?). At the beginning of run time, this reaction is deactivated by the BrowserSensor as soon as the file downloads so that until the user starts increasing a parameter, it won't decay.

c. The Switch Variable controls whether the parameter decay reaction is activated or deactivated (i.e. won't work even if triggered). The Switch Variable is the Shininess parameter of a "variable" material not used for an object surface. 0 is the value for OFF, 1 is the value for ON. To make the results of user actions look coherent, we prevent the parameter decrease from competing with the parameter increase by using a kind of master switch that turns the decay reaction OFF when the user presses the arrow key to increase the parameter. Another reaction triggered by the arrow key, but delayed (in the link) by 2 seconds, turns this switch parameter back on again.

d. The Custom Sensor continually tests the User Parameter value AND the Switch Variable. when it is the equivalent of a given minimum value, stops its decrease by deactivating the Decay Reaction. It yields a TRUE script value when the User Parameter is greater than a specified minimum value AND (i.e. both conditions are true) the Switch Variable is set to 1 (ON) and yields a FALSE script value when one or both of those conditions is false.

Operation:

User presses an Arrow Key which triggers:
1. Reaction increasing user parameter
2. Reaction setting Switch Variable to 0 (OFF)
3. Reaction setting Switch Variable to 1 (ON) - Delayed (in link) by 2 seconds

Custom Sensor continually testing:
If userparameter > minimumvalue AND switchvariable is equal to 1, then yield TRUE -> activate Increase
If userparameter < minimumvalue OR switchvariable is not equal to 1, then yield FALSE -> deactivate Increase
(“>” means greater than, “<” means less “than”)

e. Direct vs Indirect: Note that there are two basic modes of controlling the expression or display (however one has designed that) of the three parameters, direct (scale in the demo) and indirect (materials/color in the demo). Direct is where the continuously variable scale (e.g. 0-10) of the parameter value directly controls something that gets displayed, like scale. Indirect is where there is a continuously variable scale that is changed by the user and the decay reaction but its values don't affect anything directly. Instead its value range is divided up by the use of ParameterRange sensors that trigger reactions that change the display somehow. Note that the apple only has three different possible colors (via SwitchMaterial reactions) so each of the three ParameterRange sensors divide up the full range into three sections and trigger the SwitchMaterial reactions when the value comes into their individual range.