Timer
- Last UpdatedDec 07, 2023
- 3 minute read
The Timer node is used to generate time-based events and values. It can be started, paused, stopped, or reset.
-
When running with loop mode off, the timer generates a cycle event at the end of the duration time.
-
In looped mode, during each loop the alpha value moves between the minimum and maximum values set by the range parameter.
-
The alpha movement mode can be:
-
Forward (minimum > maximum, minimum > maximum)
-
Ping-pong (minimum > maximum, maximum > minimum).
-
-
You can randomly generate the time interval duration using the randomRange parameter.
-
By default, the timer works with seconds.
-
Use the durationDiv attribute, to count with another measure unit, such as frames.
Platform support
This node is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-Portable WASM platforms.
|
XR-WIN |
XR-P-WIN |
XR-P-IOS |
XR-P-AND |
XR-P-WASM |
|---|---|---|---|---|
|
Full support |
Full support |
Full support |
Full support |
Full support |
|
|
|
|
|
|
Code example
This is a code example for the Timer node.
<Timer name="timer_warp" duration="60" durationDiv="25"/>
Position
The Timer node must be inside a context node, such as Context or Global.
Timer fields
These are the fields for Timer node. Only the node-specific fields are indicated, not fields obtained by inheritance.
Field inheritance: NodeBase > Timer
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
active |
sbool |
Optional |
true |
Activates or deactivates the timer. This is a deprecated parameter. It is recommended that you use Start, Pause, and Stop instead. |
|
alpha |
sfloat |
Read only |
Internally calculated |
The current timer position within duration range, normalized between 0 and 1. |
|
cycle |
sevent |
Read only |
Not set |
Triggers at each loop interval end. |
|
duration |
sfloat |
Optional |
1 |
Sets the time interval. |
|
durationDiv |
sfloat |
Optional |
1 |
Sets a different unit measure than seconds. |
|
loop |
sbool |
Optional |
false |
When set to true, the timer runs cyclically and the alpha value is updated. |
|
mode |
senum |
Optional |
Forward |
Defines the alpha behavior during loops. If set to forward, alpha always move from range minimum to range maximum in each loop interval. If set to pingpong, alpha moves alternatively up and down between range min and max. |
|
pause |
sevent |
Optional |
Not set |
Pauses the timer. Use Start to restart it. |
|
randomRange |
svec2 |
Optional |
0 0 |
Defines minimum and maximum values for the dynamic loop interval time calculation. The time interval is recalculated only if randomRange is different from its default value: "0 0". |
|
range |
svec2 |
Optional |
0 1 |
Defines minimum and maximum value between which alpha is moved during loop interval. |
|
reset |
sevent |
Optional |
Not set |
Restarts the timer. |
|
start |
sevent |
Optional |
Not set |
Starts the timer. |
|
state |
senum |
Read only |
Internally updated |
Shows current state as Play, Stop, or Pause. |
|
stop |
sevent |
Optional |
Not set |
Stops the timer. |