Creating a Match 3 Game in Unity

Поделиться
HTML-код
  • Опубликовано: 25 янв 2025

Комментарии • 145

  • @winterboltgames
    @winterboltgames  3 года назад +13

    The link to the complete project has been updated.
    drive.google.com/file/d/1poHbfokB1QACOb3_X-V2nZw0nIL4RKNl/view?usp=sharing

    • @westparezal
      @westparezal 2 года назад +1

      If you select a cell and any non-neighbour cell, the selection will be remembered. This will lead to a bug where selecting another tile instead of the first selected one will not be possible to pop on the entire map.
      FIX to add Clear selection method:
      if (Array.IndexOf(_selection[0].Neighbours, tile) != -1)
      {
      _selection.Add(tile);
      }
      else
      {
      _selection.Clear();
      }

  • @littlephoenix
    @littlephoenix Год назад +6

    Thank you very much. I was developing a game in the style of Bubble Shooter, and my method for recursively detecting neighbors was consistently causing a stack overflow error. Your approach to this matter is incredibly concise and straightforward. You've saved me from a significant waste of time; words can't express how thankful I am. 👏❤

  • @eyedoteye
    @eyedoteye 2 года назад +6

    I love that you use advanced C# and Unity methods. I find learning through examples to be really effective for me.

    • @winterboltgames
      @winterboltgames  2 года назад +2

      Yep! learning things by actually doing them is the best way to learn!

  • @duztine
    @duztine 2 года назад +2

    A clear, easy to understand, helpful tutorial. Thank you

  • @Ertugrul170
    @Ertugrul170 Год назад +2

    A very insightful tutorial for beginners. Thank you

  • @hazelk_zpt
    @hazelk_zpt 3 года назад +3

    This was very helpful! Thank you for a great tutorial!

  • @hunter7777
    @hunter7777 2 года назад +3

    When I follow along on this video & make it from scratch, I get all sorts of compiler errors. I am using the same Unity version as you. And when I compare the code from the updated project that you have a link to, I find that the code is totally different. For instance in the code in the video you reference _selection, but it is NOT defined anywhere in the code, so it gives me all sorts of errors. So now I am stuck at around 36:00 in the video because I can't get it to work correctly.

    • @christophermercaldi8616
      @christophermercaldi8616 2 года назад +1

      if you're still stuck on this, you can define it as a List and set it as private

    • @martinknutsen2801
      @martinknutsen2801 6 месяцев назад

      I may be 2 years late but in case anyone runs into the same issue, check if the variables on the scripts in your prefabs are assigned! I ran into the same issue and noticed I had just forgotten to assign the Icon and Button on the Tile prefab, it is shown at around 29:38 if you want to see what I mean 😅
      I hope this helps!

    • @winterboltgames
      @winterboltgames  6 месяцев назад

      Legend 🔥 thanks for helping the community 🙏🏻

  • @dragontailsb1971
    @dragontailsb1971 2 года назад +1

    GREAT VID!! (it took me 2 tries but eventually it worked!)

  • @fulgencejuniorlohore5217
    @fulgencejuniorlohore5217 2 года назад +2

    Great tutorial, this was really useful!

  • @hongquanpham3730
    @hongquanpham3730 2 месяца назад +1

    I want to stack tiles from top to bottom after matching instead of replacing blank tiles with random tiles, would organizing the tiles into columns instead of rows make that easier?

    • @winterboltgames
      @winterboltgames  2 месяца назад

      It could, yes. But it would affect how you do other things as well, so keep that in mind.

  • @mr.barskih2379
    @mr.barskih2379 3 года назад +11

    Yo man. Thanks for the tutor. Would be awesome if future videos get a little bit louder. I mean in headphones is ok, but phone loudspeakers are interrupted by outside noises(in my case it's car noises from window).

    • @winterboltgames
      @winterboltgames  3 года назад +2

      I'm really grateful for your feedback! I'm going to buying a dedicated microphone as soon as I can since I already know that my headset one is quite bad.

  • @quangas
    @quangas 2 года назад +3

    Thanks for the tutorial, easy to follow.
    1. Is there anyway to make the connected tiles match and pop only for horizontal or vertical tiles only of 3 or more?
    2. How do we determine when it's game over?

  • @BinhNguyen-hh1ut
    @BinhNguyen-hh1ut 2 года назад

    At 15:00
    When I finished the script for item and go back to Unity, I got an error says
    Assets\Script\Item.cs(3,19): error CS0246: The type or namespace name 'menuName' could not be found (are you missing a using directive or an assembly reference?)
    any help for that

    • @YoshihitoBLM
      @YoshihitoBLM 2 года назад

      I was having the exact same issues but what I figured out is that I had added a letter to CreateAssetMenu. I had it as CreatedAssetMenu. Adding that d, though it looks pretty correct, messes with it.

  • @majelislaguanakindonesia2106
    @majelislaguanakindonesia2106 2 года назад +2

    great tutorial, well done.
    Do you have plan to make video about custom grid ? not just rectangle.

    • @winterboltgames
      @winterboltgames  2 года назад +2

      Thanks for your comment. Will see what I can do 😉

  • @somerndguy
    @somerndguy 2 года назад +2

    Do the gameobjects - tiles specifically, stretch when you test the game on a real device with different resolution? how to adapt to all screen sizes?

    • @winterboltgames
      @winterboltgames  2 года назад

      If you've adjusted the canvas as shown in the video then they shouldn't.

    • @somerndguy
      @somerndguy 2 года назад +1

      Thanks for answering. Actually after watching more I see that it is a different approach than what I tried, I'll test it, much appreciated.

  • @hunter7777
    @hunter7777 2 года назад +2

    When will there be an updated video tut of this? And can you show more of how to add score, timer, your own background image & have an ending to go to the next level? Thanks.

    • @winterboltgames
      @winterboltgames  2 года назад +3

      I'm currently busy with school. When I get some free time I will release an updated video tutorial that shows how to create a match 3 game in a much more easy and more performant way. Stay tuned!

    • @hunter7777
      @hunter7777 2 года назад +1

      @@winterboltgames Thanks

  • @anhkhoacao8321
    @anhkhoacao8321 2 года назад +2

    hey how to make a scoreboard with the new project?

  • @salesmart_b2b
    @salesmart_b2b 2 года назад +1

    Awesome tutorial, thank you so much

  • @loopjunkie2724
    @loopjunkie2724 2 года назад

    I got a error saying
    Severity Code Description Project File Line Suppression State
    Error CS1061 'row[]' does not contain a definition for 'Max' and no accessible extension method 'Max' accepting a first argument of type 'row[]' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp C:\Users\m\Documents\Unity\ofiical pw\Assets\scripts\board.cs 20 Active
    I'm at 20:34 part of the video

    • @winterboltgames
      @winterboltgames  2 года назад +1

      Your probably forget to add "using System.Linq" to the top of the file giving you the error.

  • @Anonymous699-b8t
    @Anonymous699-b8t 2 года назад +2

    🔥🔥🔥🔥🔥🔥🔥 Very we’ll explain!

  • @ศุภวิชญ์ดีชัย-ฟ4ถ

    when trying to click change it fast Until the image icon is stuck together and then comes up with a message that says "ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection." How should I fix it?

  • @cheesecakenl1980
    @cheesecakenl1980 Год назад +1

    Great video. There is a small bug where it stops matching tiles that are already looped over in the Pop() method. I added this at the end of the Pop() method.
    if (CanPop())
    {
    await Pop();
    }

  • @АлексейИванов-о1д1у
    @АлексейИванов-о1д1у 6 месяцев назад

    Hello, please tell me how to implement point(score) counting in the latest version of the game from 06/01/2021, thanks in advance.

  • @supershaq1
    @supershaq1 Год назад +1

    how are your using directives automatically generated

    • @winterboltgames
      @winterboltgames  Год назад +1

      www.jetbrains.com/help/rider/Settings_Auto_Import.html

    • @supershaq1
      @supershaq1 Год назад

      Oh i thought you were using vscode

  • @atanasow9648
    @atanasow9648 2 года назад +4

    Is there a copyright on your codes and can they be used for a creation of my own project?

    • @winterboltgames
      @winterboltgames  2 года назад +2

      I should've mentioned this but the code in this tutorial is free for anyone to use in their projects with no attribution required (but is appreciated).

    • @atanasow9648
      @atanasow9648 2 года назад +1

      @@winterboltgames Thats good to hear. Thanks for the quick answer 🥰

  • @UnCurieux
    @UnCurieux Год назад +1

    I'm trying to follow your tutorial and I'm stuck at the 30th minute. I've tried to download the project but the page is blocked. Would you be so kind as to fix it?

    • @winterboltgames
      @winterboltgames  Год назад +1

      Have you tried this link → drive.google.com/file/d/1poHbfokB1QACOb3_X-V2nZw0nIL4RKNl/view?usp=sharing

    • @UnCurieux
      @UnCurieux Год назад +1

      @@winterboltgames Thank you very much for your reply. The problem was with my browser. Sorry ^_^

    • @winterboltgames
      @winterboltgames  Год назад

      @@UnCurieux you're welcome 😊

  • @dragontailsb1971
    @dragontailsb1971 2 года назад +1

    How can I check if it's impossible to do a move and if so reset the board?

    • @winterboltgames
      @winterboltgames  2 года назад

      Iterate over the entire board and try switching tiles and if no matches are caused by that simply shuffle the board the repeat

  • @enderkid8563
    @enderkid8563 2 года назад +2

    tysm for tutorial this is so helpful!! =D

  • @0darkwings0
    @0darkwings0 3 года назад +2

    Hello, thank you for the great tutorial :)
    I have a question, what does this code mean?
    public Tile[ ] Neighbours => new [ ]
    {
    Left,
    Top,
    Right,
    Bottom,
    };
    I didn't see that syntax before, it looks like you create a new property that has just a "get" and you just wrote"new [ ]" without specifying what type of array you creating and filled it with all the directions you created?

    • @winterboltgames
      @winterboltgames  3 года назад +3

      In recent C# versions, you don't need to specify the type of the array if it is already known at compile time. What I did above is that I created a "computed property" which basically means a property with a getter only that can't be initialized anywhere even in the constructor though the property will be computed automatically every time you reference it. The property above simply holds all the neighboring tiles to make certain operations more convenient.

    • @0darkwings0
      @0darkwings0 3 года назад +1

      @@winterboltgames Thank you very much for your answer :)

    • @winterboltgames
      @winterboltgames  3 года назад +1

      @@0darkwings0 You're welcome 😉

  • @Hellow28276
    @Hellow28276 Год назад +1

    Thanks a lot! Helped make a cool game🎉🎉🎉

  • @ExTazYCodm
    @ExTazYCodm 9 месяцев назад

    hi bro. gives me this error. how can I solve it?
    NullReferenceException: Object reference not set to an instance of an object
    Board.Start () (at Assets/Scripts/Board.cs:33)
    script line 33 : tile.Item = ItemDatabase.Items[Random.Range(0, ItemDatabase.Items.Length)];

    • @jessewidow1255
      @jessewidow1255 6 месяцев назад

      I have this problem too-ItemDatabase dont found on chooselist and dont understand what is it. I think its one of component DOTweens or something

    • @hassanshah2129
      @hassanshah2129 4 месяца назад

      change your ItemDatabase script with ->
      using UnityEngine;
      public class Itemdatabase
      {
      public static Item[] items { get; private set; }
      [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
      private static void Initialize()
      {
      // Ensure the array gets populated
      items = Resources.LoadAll("Items/");
      if (items == null || items.Length == 0)
      {
      Debug.LogError("No items found in the 'Resources/Items' folder.");
      }
      }
      }

  • @azeddinecherbib4387
    @azeddinecherbib4387 2 года назад

    Hello How i can add other tile-types ? it's not work when i add it using this [CreateAssetMenu(menuName = "Match 3 Engine/Tile Type Asset")]

  • @estefaniaverka1327
    @estefaniaverka1327 8 месяцев назад +1

    Many thanks for the help 🌹

  • @DavidRosen3
    @DavidRosen3 2 года назад +1

    This actually is not a very performant way of handling a match game. Especially when the typical board is 7x7 or larger. Iterating through every single tile, and then recursively looking through connected tiles for matches takes too much time. A check is needed to prevent tiles that have already been checked (through recursion) from going back in the direction from which they were already checked. For example, a tile at position 3, 2 does not need to check any tiles whose x is less than 3 or whose y is less than 2.
    Also, you're deflating after every single tile you check. Instead, you should wait until you've checked the entire board to do the deflation. In the current implementation it's repeating the deflating task because (as I mentioned before), it's also checking tiles that have already been checked...and since even though they've been deflated, their tile value is still the same, they're added to the task all over again.

    • @winterboltgames
      @winterboltgames  2 года назад +1

      Thanks a lot for your comment. This tutorial was intended to help people understand how a "basic" match-three game is created. I agree that the method used to do the matching is inefficient. I've come up with a much better solution since publishing this video, and I intend to do a video when I've time.
      Again, thanks a lot for your comment 💖 it is rare to see someone criticising you and giving you helpful advice these days.

    • @DavidRosen3
      @DavidRosen3 2 года назад +1

      @@winterboltgames looking forward to seeing it!

  • @solitudeau8188
    @solitudeau8188 Год назад +1

    After a year and a half away from game dev my friend from university and I figured we would try a matching game to get back into the swing of things. Working entirely from scratch we almost had it done. Out of curiosity as I lay here before bed I wanted to see how others went about it and my theory (including the paint drawing 😂) is bang on the money with how you have done it (save for setting up the grid). I’ve used lists before but haven’t set up a grid system but I didn’t want to go down that path if I could avoid it.
    Looks like I’ve still got it 😂 great vid

  • @stepintoultimathule2217
    @stepintoultimathule2217 2 года назад

    thank you, this is a very cool video

  • @vicious3526
    @vicious3526 2 года назад

    Getting a fault
    IndexOutOfRangeException: Index was outside the bounds of the array.
    MatchThreeEngine.Board.Start () (at Assets/Scripts/MatchThreeEngine/Board.cs:65
    Any ideas?

    • @dominusnox691
      @dominusnox691 2 года назад

      found it, damn it! Make sure your Resource folder named "Resources" not "Resourses"

    • @navelak
      @navelak 2 года назад

      Is your board nxn ? I had that error when I created a 5X7 board, I think they must be the same rows and columns in order to work

    • @winterboltgames
      @winterboltgames  2 года назад

      The board can be of any dimensions. You *don't* need a square board. You can have a spiral board and everything will work just fine if you follow the tutorial carefully.

    • @navelak
      @navelak 2 года назад +1

      @@winterboltgames Then I will have to rewatch it very carefuly! Thanks for the awesome video and the fast response. You rock sir!
      EDIT: Found the error. I had a mess with the tile neighbours (which error, ironically, did not manifested in square matrix)

    • @winterboltgames
      @winterboltgames  2 года назад

      @@navelak 🙂

  • @joecratic
    @joecratic 3 года назад

    is the link to the complete project still available

  • @spyrosspyrou4636
    @spyrosspyrou4636 3 года назад +1

    I did follow every single step until 31:09 but my Sprites are yet not shown. Any ideas? Who can help me!

    • @winterboltgames
      @winterboltgames  3 года назад +1

      Quickly scrub through the video and take multiple looks at the code to make sure that you did follow everything correctly.

    • @udhaisrinivasan1472
      @udhaisrinivasan1472 3 года назад

      Iam also having same problem 🥲

    • @udhaisrinivasan1472
      @udhaisrinivasan1472 3 года назад

      @@winterboltgames but code also correct but animals image are yet not shown

    • @ElementofWorship
      @ElementofWorship 3 года назад

      Are the sprites behind the background layer?

    • @kadalfi2004
      @kadalfi2004 2 года назад

      Same pretty much but I'm getting this message
      IndexOutOfRangeException: Index was outside the bounds of the array.

  • @mediatv111
    @mediatv111 2 года назад

    How to copy paste auto increase (tile_1, tile_2...)

    • @etrigan966
      @etrigan966 2 года назад +3

      Project Settings > Editor > Numbering Scheme

    • @mediatv111
      @mediatv111 2 года назад

      @@etrigan966 Thank u !!!

  • @vasosvasileiadis7978
    @vasosvasileiadis7978 2 года назад

    The script for the score seems to not working. Any ideas please??

    • @winterboltgames
      @winterboltgames  2 года назад

      What is not working exactly? I suggest that you scrub through the video quickly and see if you missed or done anything incorrectly.

    • @vasosvasileiadis7978
      @vasosvasileiadis7978 2 года назад

      @@winterboltgames in the scorecounter script some errors apout TextMeshproUGUI and for serializeField

    • @winterboltgames
      @winterboltgames  2 года назад +1

      @@vasosvasileiadis7978 You need to have both of TextMeshPro and UnityEngine namespaces in order for the errors to go away.

    • @vasosvasileiadis7978
      @vasosvasileiadis7978 2 года назад +1

      it seems to be ok in the scorecounter script but in the board script when i write this
      ScoreCounter.Instance.Score += tile.Item.value * connectedTiles.Count;
      it has an error that the name tile does not exist in the current content

    • @winterboltgames
      @winterboltgames  2 года назад +1

      @@vasosvasileiadis7978 You probably missed a variable declaration. Please, re-watch the part of the video where this is implemented again.

  • @LucianoThePig
    @LucianoThePig 2 года назад +1

    Great video, Is there a way to have different effects when certain blocks match? like if you match some red blocks you get more points or something

    • @winterboltgames
      @winterboltgames  2 года назад

      Thanks for your comment. You can the match animation function so it also creates a particle system or does whatever you want.

  • @wiglord
    @wiglord 2 года назад +1

    So for my next new project I'm going to make a multiplayer dungeon battler where each player will try and solve these matches to launch attacks at monsters. Yay fnet! :)

    • @winterboltgames
      @winterboltgames  2 года назад

      Good luck!!

    • @wiglord
      @wiglord 2 года назад

      @@winterboltgames Just got through it now, followed the video and up until the last bit I was like "but I can move tiles from anywhere!" But I figured I could put a check for the neighbours in the selection method anyway xD so was happy to see the updated video. But I have a bug. If you click again while the tiles are moving, you select a third tile and the two moving tiles stop halfway and remain bugged in that position even if they pop. I think I have to put in a check or bool somewhere to prevent selecting while the game is actively moving

    • @winterboltgames
      @winterboltgames  2 года назад +1

      @@wiglord I'll release a much better tutorial soon (once I get a new mic 😂) that will solve all of the old problems and allow for more features.

  • @ilianostapovich4378
    @ilianostapovich4378 2 года назад

    someone has did it but with the match 3 on a line instead of in any direction? i mean 3 horizontals or 3 verticals intead of 2 verticals and 1 horizontal, for example

    • @winterboltgames
      @winterboltgames  2 года назад

      You need to tweak the code yourself to suite your use case but yes, it is doable.

  • @etrigan966
    @etrigan966 2 года назад +1

    Thank you so much for the video and clear explanations you explained some of the more complex parts really detailed and easy to follow.
    You suggested making on shuffle algorithm on start to make sure there is no matching tiles to begin with, how would I go about doing that?
    Thank you again for taking the time to this tutorial I don't know whether you will see this or not but thank you regardless.

    • @winterboltgames
      @winterboltgames  2 года назад +2

      I'm going to be releasing a new and improved tutorial soon. Stay tuned 😉

    • @etrigan966
      @etrigan966 2 года назад

      @@winterboltgames Awesome cant wait! However would you mind pointing me in the right direction regarding that, I could use that small quality of life addition. Thank you again. :)

    • @etrigan966
      @etrigan966 2 года назад

      I've tried to in the loop to populate the board inside the Start method to maybe check for Neighbours but cant figure out the syntax, is there a way to stop the score from accumulating while using the Pop() at the start - I think i'll try to use that as an alternative
      Edit: So sorry to be annoying but shouldn't this work snipboard.io/x7yXcR.jpg :/ - Edit again nevermind figured something out

  • @acez28
    @acez28 2 года назад +1

    Finally finished the tutorial
    Great learning experience for me
    Love the video
    But I encouraged a 2 bugs
    if you swipe while an item is still swiping the game crashes
    And also when you select an object and select another object far off then select two other objects that a close to each other it doesn't swipe...it still wants to swipe with the first object you selected
    Also can you do a tutorial on powered up items... like matching 4 will give another item etc and stuff like matching items in a straight line?
    ♥️sub

    • @itsanaz
      @itsanaz 2 года назад

      Hello please help me. In this time: 31:24 , when I want to click on sprite or tile in game mode , I have no tile selection or reaction . Do you know how can I do it ? After onclick code I have this problem too.

  • @atakanaymankuy9772
    @atakanaymankuy9772 Год назад

    i wrote exactly what you wrote but i encountered 2-3 errors. No animal images appear in the upper left corner and i get an error when i press it. Pressing the A key grows all boxes that are not matched. When i type the code exactly, the matching boxes do not disappear.

  • @arminnajafi9297
    @arminnajafi9297 3 года назад +2

    link of complete proj doesnt work

    • @winterboltgames
      @winterboltgames  3 года назад

      Oh, something must have gone wrong then. I'll re-upload and let you know later today. Thanks for bringing this up!

    • @MuhammadShahid-co8yt
      @MuhammadShahid-co8yt 3 года назад

      @@winterboltgames Hello, still not working?

    • @winterboltgames
      @winterboltgames  3 года назад +1

      Sorry. I'm going to post it right away. Just give an hour.

    • @MuhammadShahid-co8yt
      @MuhammadShahid-co8yt 3 года назад

      @@winterboltgames Thanks and please do quickly

    • @winterboltgames
      @winterboltgames  3 года назад

      @@MuhammadShahid-co8yt drive.google.com/file/d/1poHbfokB1QACOb3_X-V2nZw0nIL4RKNl/view?usp=sharing

  • @acez28
    @acez28 2 года назад

    System.Linq doesn't have the rows.max

    • @winterboltgames
      @winterboltgames  2 года назад

      Max is an *extension method*. You simply need to import System.Linq and it will become available.

    • @acez28
      @acez28 2 года назад

      @@winterboltgames but I did import the
      Using System.Linq

    • @acez28
      @acez28 2 года назад

      @@winterboltgames oh I'm really sorry
      Just had to update my Visual studio

    • @acez28
      @acez28 2 года назад

      Everything is working fine now

  • @T.H.U.2024
    @T.H.U.2024 Год назад

    Bro but your Video Resolution is not Available

  • @publikumsorientiert
    @publikumsorientiert 4 месяца назад +1

    感恩

  • @greymow
    @greymow 2 года назад

    any easy way to make this for mobile?

    • @winterboltgames
      @winterboltgames  2 года назад

      Simply build your app for Android/iOS and everything should work.

  • @dezstslkerq7159
    @dezstslkerq7159 Год назад

    ndexOutOfRangeException: Index was outside the bounds of the array.
    MatchThreeEngine.Board.Start () (at Assets/Assets/Scripts/MatchThreeEngine/Board.cs:65) ???

  • @axay06
    @axay06 3 года назад

    Sometimes items don't Pop when they are matched

  • @westparezal
    @westparezal 2 года назад +1

  • @vivajest5812
    @vivajest5812 Год назад

    I am stuck at this error, rewatched the video multiple times, but I cant seem to solve it, please help:
    IndexOutOfRangeException: Index was outside the bounds of the array.
    MatchThreeEngine.Tile.get_Bottom () (at Assets/Scripts/Tile.cs:31)
    MatchThreeEngine.Tile.get_Neighbours () (at Assets/Scripts/Tile.cs:32)
    MatchThreeEngine.Tile.GetConnectedTiles (System.Collections.Generic.List`1[T] exclude) (at Assets/Scripts/Tile.cs:46)
    MatchThreeEngine.Tile.GetConnectedTiles (System.Collections.Generic.List`1[T] exclude) (at Assets/Scripts/Tile.cs:49)
    Board+d__20.MoveNext () (at Assets/Scripts/Board.cs:111)
    --- End of stack trace from previous location where exception was thrown ---
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at :0)
    System.Runtime.CompilerServices.AsyncMethodBuilderCore+c.b__6_0 (System.Object state) (at :0)
    UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at :0)
    UnityEngine.UnitySynchronizationContext:ExecuteTasks()

  • @Anonymous699-b8t
    @Anonymous699-b8t 2 года назад +1

    🔥🔥🔥🔥🔥🔥🔥 Very we’ll explain!