ℹ️ 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 door that blocks the way and a key. Without the key, the door stays shut. With the key, it disappears when the hero touches it.
You need:
- a 2D project open in Yop2D Next.
Step 1: the cle variable
- Left panel, Scene tab, GAME VARIABLES section: tap New variable. Name (no spaces): cle; Type: Whole number; Starting value: 0. Then Apply.
Step 2: the hero
- Put an object in the scene (an image or a Square) and name it heros.
- Select heros, tap ⚙ Object behavior in the Inspector and choose Top-down character.
- Tap Object → Interactive → Joystick.
Step 3: the key
- Put an object in the scene (an image or a Square) and name it cle_obj.
- In the Inspector, Tag (family of objects) line, type cle.
Step 4: the door
- Put an object in the scene (an image or a Square) and name it porte.
- In the Inspector, Tag (family of objects) line, type porte.
- Select porte, tap ⚙ Object behavior in the Inspector and choose Ground / wall.
Step 5: the nodes
- Open the Blueprint.
- If object touches Tag: Object heros, Tag (family of objects touched) cle → Destroy Object: Object The involved object (the touched object) → Modify Variable: Variable cle, Value 1
- If object touches Tag: Object heros, Tag (family of objects touched) porte → If a variable…: Variable cle, Comparison is at least, Value 1
- True output → Destroy Object (Object porte)
The nodes
If object touches Tagheros · cle
→
Destroy ObjectThe involved object (the touched object)
→
Modify Variablecle · 1
If object touches Tagheros · porte
→
If a variable…cle · is at least 1
True →
Destroy Objectporte
Try it
Tap Play. Touch the door: it doesn't open. Pick up the key, touch the door again: it disappears.
👉 For a door that opens instead of disappearing: replace Destroy Object with Change Image (an open-door image) and remove its behaviour.