← Yop2D

How to make a tactics game?

Beginner guide · no code

Français · English · Español · Deutsch · Italiano · Português · Русский · 中文 · 日本語

In a tactics game, players take turns on a grid: you choose a unit, see the cells it can reach, move it, then it attacks. This guide builds the simplest game possible: one hero and one monster. Everything is already done in the Tactics tutorial example (Examples tab of the start screen): open its Blueprint, each step is in a colored frame with a small ? that explains it.

You need:
👉 Terrains (forest, sand, mountain…) are set in the tile editor, Terrains of the tiles part: step cost, blocked or not, defense bonus. The mountain blocks the way, the forest costs 2 steps.

Step 1: the unit sheets

  1. Add the “On Start” event.
  2. Add “Give a unit sheet” for hero1: health 20, attack 6, defense 2, movement 4, range 1.
  3. Add a second “Give a unit sheet” for foe1, with its own numbers.
  4. Link the nodes in order, then add “Go to the next turn” with the teams joueur,ennemi.
👉 The sheet is stored in the object: you can read it anywhere with a formula, for example =hero1.vie.

Step 2: the player's turn

  1. Add the “Local Event” event and write the name tour_joueur. It starts by itself at the beginning of the player's turn.
  2. Set etat to 0 with “Modify Variable”, then “Hide the cells” to clear the old cells.

For each team, “Go to the next turn” runs the local event "tour_" followed by the team name: tour_joueur, then tour_ennemi.

Step 3: touch the hero, see the blue cells

  1. Add “On Object Click” on hero1.
  2. Add “If it is the turn of…” with the team joueur, then on the True output a “Condition” etat < 2.
  3. Add “Modify Variable”: etat = 1.
  4. Add “Show reachable cells” on hero1: zone type Movement (walls count), number of steps =hero1.mouvement, blue color, Write the step count on each cell = yes, These tags block the way = joueur,ennemi.
👉 The numbers on the cells are the steps needed to get there. Forest cells cost 2: the hero goes less far.

Step 4: touch a blue cell, the hero walks

  1. Add “On Object Click” on terrain, then a “Condition” etat = 1.
  2. Add “If the cell is reachable”. For the column and the row, touch 🔗 and choose the green nodes “Touched column” and “Touched row”: no formula to write.
  3. On the True output: “Modify Variable” etat = 4 (the hero is walking), then “Go to the cell (path)” on hero1, with the same green nodes and These tags block the path = joueur,ennemi.
  4. On the Arrived output, call the local event apres_deplacement with “Call event”.

Step 5: the attack zone, then the attack

  1. In the local event apres_deplacement: “Hide the cells”, etat = 2, then “Show reachable cells” with type Attack / range (goes over walls), number of steps =hero1.portee, red color, with the zone name attaque.
  2. Add “On Object Click” on foe1, a “Condition” etat = 2 and “If the cell is reachable” with the zone name attaque.
  3. On True: “Attack” (object A = hero1, object B = foe1). Damage is the attack, minus the monster's defense, minus its terrain's defense.
  4. Still alive output: update its health text. Out of health output: the monster is destroyed, add the victory.

Step 6: the monsters' turn

  1. Add the local event tour_ennemi.
  2. Add “Go to an object (path)” on foe1, object B = hero1, Stop = On a neighbor cell, centered, These tags block the path = joueur,ennemi.
  3. On the Arrived output, call a local event where foe1 “Attack” hero1.
  4. After a few seconds (“Wait”), “Stop the path” then “Go to the next turn”: the turn goes back to the player.

Going further

If it does not work