← Yop2D

How to shoot a projectile?

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 Fire button: each tap shoots a bullet from the hero. The bullet is a hidden model: Yop2D makes a copy of it for each shot.

You need:

Step 1: the hero

  1. Put an object in the scene (an image or a Square) and name it heros.

Step 2: the shot's model

  1. Put an object in the scene (an image or a Square) and name it balle.
  2. Make it small and untick Visible in the game: it is the model, Yop2D makes copies of it.

Step 3: the button

  1. Tap Object → Interactive → Button with text.
  2. Name it feu and type Fire in its Text line.

Step 4: the nodes

  1. Open the Blueprint.
  2. On Object Click: Object feu
  3. Shoot an object: Object heros, Model name balle, Direction 0 (to the right)

The nodes

On Object Clickfeu
→
Shoot an objectheros · balle · 0

Try it

Tap Play, then Fire: a bullet flies to the right. It disappears when it leaves the screen.

👉 Direction: 0 = to the right, 90 = down, 180 = to the left, 270 = up.