Button that advances the state
The simplest interaction: one button, one state transition, no Customized Action.
Goal
A button the participant can press to advance from the current state to the next one — no JavaScript required.
Smallest setup
- A LUIDA scene with at least two states defined in
LUIDA › Configure experiment automation → State Machine. - A CCK-compatible button mesh in the scene (a 3D model, a quad, a primitive cube — anything you can attach a CCK trigger to).
The recipe
Make the button a CCK item
Select your button GameObject. In the Inspector, add the CCK component Item (AddComponent → Cluster → Item). This makes the GameObject a Cluster-network-aware object that can host triggers and gimmicks.
Attach an Interact Item Trigger
On the same GameObject, add the CCK component Interact Item Trigger (AddComponent → Cluster → Triggers → Interact Item Trigger). This is the trigger that fires when a participant clicks or pulls-trigger on the button in VR.
Configure the trigger to send the signal toNextState:
| Field | Value |
|---|---|
| Trigger | Item (this item) |
| Specify Target | (off) |
| Key | toNextState |
| Type | Signal |
Attach a Luida To Next State Gimmick
On the same GameObject, add Luida To Next State Gimmick (AddComponent → Cluster → Gimmicks → Luida To Next State Gimmick).
Set its trigger key to match the signal name you just used: toNextState.
That's the whole wiring.
Add the button to a state
Open LUIDA › Configure experiment automation → State-listening Items. Make sure the button item is visible (ShowItem action) in whichever state the participant should be able to press it, and hidden (HideItem) in states where it shouldn't be visible. This is the same pattern as any other state-listening item.
Press Play in CSEmulator. When you click the button in the state where it's visible, the state machine advances to the next state.
Why this works
ToNextState() is the action that fires the state_triggerTransition signal, and Luida To Next State Gimmick is the CCK-side equivalent — same signal, but reachable from a plain CCK trigger without a Customized Action. The Interact Item Trigger handles the participant's click event; the gimmick translates the click into the state-machine transition signal.
You'd reach for ToNextState() (the JavaScript action) when the advance has to happen on a non-click event — a timer, an arbitrary condition, a text input submit. For "the participant clicks something to advance," the gimmick path is shorter.
See Reference → ToNextState for the action equivalent.
Variants
Multiple buttons, each advancing. Repeat the recipe for each button. They all send toNextState (the signal name doesn't have to be unique) and trigger the same gimmick. Any one of them being pressed advances the state.
Auto-advance after a timer instead. Don't put a button in the scene. Instead, on a controller item's On State Start, add a Sleep followed by ToNextState:
Sleep(3000);
ToNextState();Advance only if a condition variable matches. Toggle the if flag on the action row in the state-listening editor and gate on a CONDITION value. The Stroop tutorial uses this pattern for response-correct branches.
Where to go next
- Tutorial 1 → Priming Effect — the
StartVideoButtonstep is exactly this recipe in context. - Tutorial 2 → Stroop Effect — the Answer_Red / Answer_Blue buttons use this same pattern.
- Reference → ToNextState — the action card.
- Concepts → State machine & trial lifecycle — what "the next state" actually means and when transitions fire.