← Yop2D

How to play a sound effect on contact?

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 sound when the hero touches a coin. The coin has a tag (a family of objects): the same node works for every coin.

You need:

Step 1: the hero

  1. Put an object in the scene (an image or a Square) and name it heros.
  2. Select heros, tap ⚙ Object behavior in the Inspector and choose Top-down character.
  3. Tap Object → Interactive → Joystick.

Step 2: the coin

  1. Put an object in the scene (an image or a Square) and name it piece.
  2. In the Inspector, Tag (family of objects) line, type piece.

Step 3: the nodes

  1. Open the Blueprint.
  2. If object touches Tag: Object heros, Tag (family of objects touched) piece
  3. Play sound: Sound file line → Import or listen to sounds… → Sound effects family, choose a sound.

The nodes

If object touches Tagheros · piece
→
Play sound

Try it

Tap Play and make the hero touch the coin: you hear the sound.

👉 To pick up the coin and count points: see the A score on screen recipe.