← Yop2D

How to make a two-player game on one tablet?

Beginner guide · no code

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

ℹ️ Needs Yop2D version 1266 or newer (the last number of the version, for example 1.0.1266). If your version is older, update Yop2D.

On a tablet, two people can play at the same time: each player has their own joystick and their own character. Yop2D follows each finger separately (multi-touch), so both characters move together, without any node.

You need:

Step 1: two characters that walk by themselves

  1. Select player1, then tap ⚙ Object behavior in the Inspector.
  2. Choose Top-down character (or Platform character).
  3. On the Controls line, keep Joystick.
  4. Do the same for player2.

Step 2: two joysticks

  1. Add a Joystick object to the scene (category Interactives) and put it at the bottom left.
  2. Add a second one and put it at the bottom right.
  3. Give them clear names: joystick1 and joystick2 (the last step explains why this helps).
👉 A different color for each joystick helps the players: in the Inspector, change the color of each one.

Step 3: one target for each joystick

  1. Select joystick1. In the Inspector, section “Joystick Control”, tap the “Object to move” button and choose player1.
  2. Select joystick2 and choose player2 the same way.
  3. Save, then start the game.

Put one finger on each joystick: both characters move at the same time, each one with its own joystick. Lift one finger and only that character stops.

👉 A finger that holds a joystick keeps it until you lift it, even if it slides outside the circle. It cannot take the other joystick.

Go further: read each joystick in a formula

The first joystick keeps its usual formulas: joystick.x, joystick.y, joystick.force, joystick.angle, joystick.actif. For the others, give the joystick a name that starts with “joy”, then use the same words after the name: joystick2.x, joystick2.y, joystick2.force, joystick2.angle, joystick2.actif.

For example, to move an object that is not a character with the second joystick, use “Push object” linked to “Every frame” with =joystick2.x * 5 and =joystick2.y * 5.

Two ninjas on a meadow with two joysticks at the bottom, one blue and one orange
The “Two players” template: one joystick for each player.
👉 A joystick named like this no longer gives its screen position with .x and .y: they give the direction pushed (between -1 and 1).

Jump buttons for each player

Platform characters can also have their own jump button: in ⚙ Object behavior, choose a different button for each character in Jump button. Multi-touch lets both players press at the same time.

The “Two players” template shows all this ready to use: two ninjas, two joysticks, and no node.

If it doesn't work