← Yop2D

How to show a slider's value?

Beginner guide · no code

Français · English · Español · Deutsch · Italiano · Português · Русский · 中文 · 日本語 · العربية

ℹ️ For Yop2D Next, the new 2D + 3D version of Yop2D (coming soon). Button and node names are those of Yop2D Next.

🔍 How do I…? All short recipes, with a search

A slider the player drags (for example the volume), and a text that shows its value. Two objects, two nodes.

You need:

Step 1: the slider

  1. Tap Object at the top of the editor, category Interface elements, then Slider.
  2. In the Inspector, type its name at the very top: volume.
  3. In the Inspector, tap the Settings and style… button: a window opens. Set Minimum value 0, Maximum value 100, Starting value 50, then close it.

Step 2: the text

  1. Tap Object → Texts → Text, and place it under the slider.
  2. Name it volume_label and type 50 in its Text line (the starting value).

Step 3: the nodes

  1. Open the Blueprint.
  2. Add When an interface element changes and choose the Object volume: it fires when the player lets go of the slider.
  3. Add Modify Text, Object volume_label, and type in New text: =volume.progression.
  4. Connect the two nodes.

The nodes

When an interface element changesvolume
→
Modify Textvolume_label · =volume.progression

Try it

Tap Play, drag the slider and let go: the text shows its value, a whole number between 0 and 100.

👉 =volume.progression means: the value of the volume object. It also works for a switch or a checkbox (0 or 1).
👉 To see the text change while dragging, replace the event with Every frame.
👉 To keep the value in a variable (and use it elsewhere): the slider's Settings and style… button, Variable that receives the value (optional) line → New variable…