Skip to content

Tutorial: Writing Values

A Reactor reacts to values. To write values, use a Process Component that runs a Value Command. Each operation in the command reads from one place and writes into another: a value asset, a Data Storage key, a component field. Everything is set up in the Inspector.

By the end of this tutorial you'll have a Process Component that:

  • Copies a value from an asset into a Data Storage key when it starts.
  • Moves a value smoothly over time.
  • Writes a GameObject into a slot while it runs, and clears it when it stops.

You'll also see where measurements and one-off Data Storage writes fit.

Prerequisites: Basic familiarity with Data Storage, Keys, and the Process system.


How It Fits

Three pieces, each picked from a menu:

  1. Process Component: decides when the writes happen. By default it starts when the GameObject is enabled and stops when it is disabled.
  2. Value Command: the process it runs. It holds a list of operations and runs them together.
  3. Operations: each one names its own Source (where the value comes from) and its own Sink (where it is written).
flowchart LR
    PC["Process Component<br/>(when)"] --> VC["Value Command"]
    VC --> W1["Write Float<br/>source: Base Health asset"]
    VC --> W2["Set Vector3 Over Time<br/>sink: a position value"]
    VC --> W3["Write GameObject While Active<br/>sink: Current Tool slot"]
    W1 --> K["Health key<br/>in a Data Storage"]

Because every operation carries its own sink, the command itself has no target. You can mix writes to an asset, a key, and a component in one list.


1. Add the Process Component

Create a GameObject, or use an existing controller. Add a Process Component.

Add Component → Jungle → Process → Process Component

In its Process field, pick Value Command. The command shows an empty Operations list.

Inspector
Process Component? ⇅ ⋮
Process
Start & Stop
ProcessValue Command
Operations0+
No operations
A Value Command with nothing in it yet. The + on Operations adds the first write.

2. Write a Value Once

  1. Click + on Operations and pick Write Float.
  2. Source: where the number comes from. For example, Float Value From Asset pointing at a BaseHealth asset.
  3. Sink: where it goes. Pick Float From Data Storage, set its storage to PlayerStats and its key to Health. The picker lists every place that can take a number: a local value, a value asset, a Data Storage key, a component field.
Field Value
Source Float Value From Asset (BaseHealth)
Sink Float From Data Storage (PlayerStats, Health key)

A Write operation finishes at once. The value is copied each time the Process Component starts.

The same shape exists for other types: Write Int, Write Long, Write Bool, Write String, Write Vector3, and Write GameObject.

Operations1+
Operation 1Write Float
SourceFloat Value From Asset1
Value AssetBaseHealth
SinkFloat From Data Storage2
Data StoragePlayerStats (Data Storage Component)
KeyHealth
Use Fallback
Write Float: read the BaseHealth asset, write it into the Health key.
  1. Source: where the number comes from.
  2. Sink: where it is written.

3. Move a Value Over Time

To change a value gradually instead of in one step, add a Set Float Over Time operation (or Set Int Over Time, Set Double Over Time, Set Vector3 Over Time, Set Vector2 Over Time, Set Rotation Over Time).

Field Value
Sink Float From Data Storage (PlayerStats, Health key)
Destination Float Over Time: 0 to 100 over 1.5 s, with an ease
Modifiers (optional) Smoothing, spring, noise, clamp. Each has a blend factor.

It runs the same pipeline as every other "Over Time" operation in Jungle, so finishing, reverting, and pausing work the same way. To follow a moving source instead of playing a fixed tween, pick Float Value as the destination and add a smoothing modifier.


4. Hold a Value While Running

Write GameObject While Active writes a GameObject into its sink when the Process Component starts. When the component stops, it clears the sink again, but only if the sink still holds that object.

Use it for "this is the current tool while I'm enabled" or "this hand is the active hand while held".

Add To Container While Active works the same way for containers: the objects join the container while the operation runs, and leave it when it stops.


5. Measurements

Measurements have their own command. In the Process field, pick Measurement Command instead of Value Command. Set its Target to the object to measure, then add measurements such as Speed, Position, or Distance Traveled. Each measurement writes into its own sink, for example a Float From Data Storage key.

For joints, use Joint Measurement Command. For Octoputs attach counts and hold times, use Attachable Object Measurement Command or Attachment Point Measurement Command.

To run measurements and writes from one component, pick Process List and add both commands to it.

See the measurement tutorial for a full walkthrough.


6. One-Off Writes From Other Processes

A Value Command is not tied to a Process Component. Drop it into a Reactor's process or a state's process and it writes when that process runs.

To work on the entries of one Data Storage, use a Data Storage Command. It picks the storage once and runs its operations against it by key: Set Float, Set Int, Toggle Bool, Increment Float, Increment Int, Clear, and more. Accumulate Float adds an input into a stored number every frame, for running totals and timers.


7. Choosing When It Runs

Like every ControllableComponent, the Process Component has an Execution Frame that decides when it starts and stops. The default is on enable / on disable. You can switch to:

  • Mono Lifecycle Frame: bind to Start, OnEnable, OnDestroy, and so on. Start / OnDestroy is the usual choice for a one-time setup write.
  • Event Frame: start on one event, stop on another.
  • Targeted Cycle Frame: follow another component's cycle, such as an Attachable's Attached cycle or an Agent's Holding cycle.

What it writes (the operations) is independent of when it writes (the frame).


Next Steps