Studio Yotsuba
Back to Node List

Switch

switch

Selects one of two already-evaluated values. This is value selection, not a lazy if statement

Reviewed
Guide available

Input Ports

NameTypeDescription
True Value
true_value
Any
Returned when Condition is true
False Value
false_value
Any
Returned when Condition is false

Output Ports

NameTypeDescription
Value
value
Any
Selected value

Parameters

NameTypeDefaultRangeDescription / Options
Value Type
value_type
Enum
Float—

Choose which type this switch should pass through

  • NumberNumber
    Switch between numeric values (Float or Int)
  • FloatFloat
    Switch between float values
  • IntInt
    Switch between integer values
  • BoolBool
    Switch between boolean values
  • ColorColor
    Switch between colors
  • TextText
    Switch between text values
  • ImageImage
    Switch between images
  • PathPath
    Switch between paths
  • PixelLinePixelLine
    Switch between pixel lines
  • Vec2Vec2
    Switch between 2D vectors
  • Vec3Vec3
    Switch between 3D vectors
  • OklchAdjustOklchAdjust
    Switch between OKLCH adjustment sets
  • PalettePalette
    Switch between palettes
  • ListList
    Switch between lists
  • MapMap
    Switch between maps
  • IsoItemIsoItem
    Switch between iso items
  • IsoSceneIsoScene
    Switch between iso scenes
  • IsoWorldIsoWorld
    Switch between iso worlds
  • AnyAny
    Advanced: allow any type. Downstream nodes may fail if the selected value type does not match what they expect.
Condition
condition
Bool
false—

If true, outputs True Value; otherwise False Value

What is it for?

  • Switching values based on a condition
  • Branching from the result of Compare
  • Choosing between two colors, numbers, paths, or other values

Overview

Selects which of two already-evaluated values to pass downstream from a Bool condition. It can switch numbers, colors, images, paths, or any other type chosen with value_type. It is a value selector, not a lazy programming-language if that skips the unselected branch.

Usage tips

  • The basic pattern is compare.result → switch.condition, with condition promoted to an input pin 📌. The output switches when the value crosses the threshold.
  • Switching images creates a minimal two-state animation. motion (Blink) → compare → switch<Image> alternates between two images.
  • For three or more choices, value_select selects by index more directly. Deeply nested Switch nodes become hard to read.
  • Choose value_type correctly. Use Any only as a last resort because it disables type checking.

Related nodes

  • compare — create the condition
  • value_select — select among N choices by index
  • gate — stop a value instead of choosing one
  • expression_bool — build a Bool from a compound condition

Notes

  • You can promote condition to an input pin. Connecting the result of Compare directly is the go-to setup.
  • When both sides have upstream nodes, normal graph evaluation runs both upstream branches before Switch selects the delivered value. It does not suppress work, side effects, or errors on the unselected side like a lazy if statement.
  • Only the selected side is required. The unused side may be unconnected.
  • If the selected side is unconnected, Switch itself emits no warning and produces an empty output. A downstream node may warn that its input is unconnected.
  • Changing value_type also changes the types of true_value / false_value / value.
  • Normally, feed true_value and false_value with the same type.
  • Any is for advanced use. A connection may be accepted, but if the selected value does not match the type expected downstream, evaluation produces a warning or node error.

Examples

  1. Switch between 0 and 1 from the result of Compare
    • Produces a flag value.
  2. Switch between two colors from the result of Compare
    • Colors the output according to state.
  3. Switch between two Path values
    • Useful when different modes require different shapes.
  4. Pass the output of Switch<Float> to Math Op
    • Sends the branched value directly to the next stage.
  5. Replace a value for debugging with Switch<Any>
    • This is safe only when the downstream setup accepts Any.
Back to Node List