--- generated_by: gdlink-build generated_at: 2026-06-23T12:34:28Z do_not_edit: true title: State brick_type: gate tier: Basic generated: true --- # State **Category:** Gate **Tier:** Basic ## Purpose Implements a finite state machine (FSM) gate that only activates outputs when in specific states, with bitmask-based state filtering. ## Visual Reference ```{raw} html
As added to your scene
State brick as it appears in the GDLink editor
``` ## When To Use - Character state machines (idle, walk, run, jump, attack) - Enemy AI states (patrol, chase, attack, retreat) - UI states (main_menu, settings, gameplay, paused) - Animation states (sequence control) - Game flow states (intro, gameplay, victory, game_over) ## Runtime Behavior **Triggers**: When the object's current state matches the gate's state mask ```{raw} html
Generated UI Mockup — showing expanded properties
State
-
x
Name:
Label this brick...
State Mask:
1
v
``` ## Properties | Property | Type | Default | Notes | |---|---|---|---| | state_mask | Integer, 1 | | Bitmask of states - 1=state0, 2=state1, 4=state2, etc | ## Example Use Cases **Character State Machine**: ``` // Define states: // 0 = idle // 1 = walking // 2 = running // 3 = jumping // Idle state State(current=0, mask=0b0001) -> Animation(idle) // Walking state State(current=1, mask=0b0010) -> Motion(walk_speed) // Running state State(current=2, mask=0b0100) -> Motion(run_speed) // Jumping state State(current=3, mask=0b1000) -> Motion(jump) ``` **State Transitions**: > Sample inspector layout removed for compatibility. **Multiple States Active**: ``` // Gate activates in BOTH idle AND walking states State(mask=0b0011) -> Animation(upper_body_idle) // Allows upper body idle animation while lower body walks ```