GameDev Tutorial: HowTo make a Dynamic Grid in Unity C# (2d sprites)

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

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

  • @LostRelicGames
    @LostRelicGames  5 лет назад +9

    Hey guys! I'd love to get your feedback on the game I'm making, pls let me know what you think : ruclips.net/video/t4jnuktZm7I/видео.html

  • @LostRelicGames
    @LostRelicGames  5 лет назад +8

    I hope you enjoy this tutorial! If you have any questions, leave them below and I'll be happy to answer.

    • @MyAfricanCats
      @MyAfricanCats 4 года назад +1

      It was a great tutorial. Thanks a lot. Could you please explain how can we use this to make simple board games such as dots and boxes? I am mainly interested to know how we can define objects on the board and move them horizontally, vertically or even diagonally by mouse click. I would be grateful if you could explain or even make another great video which is very helpful for beginners like me.

    • @yeost187
      @yeost187 4 года назад

      I know this is a year old but TY for doing this. However, could you maybe, possibly categorize this playlist a little more? Its a bit hard coming here after so much time has past, and trying to piece it all together. Even if you don't? still ty for doing these.

    • @robertocravioto2623
      @robertocravioto2623 4 года назад

      Simple and to the point, nicely done, Its there a way to create the grid using a sprite folder with multiple images without repeating?.

  • @moduntilitbreaks
    @moduntilitbreaks 4 года назад +10

    Can't wait for the next video. This feels like a solution which would scale nicely even for bigger games. Subscribed!

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

    Hey John I don't know if you will even see this but thank you so much man, this tutorial really helped me out a lot on a game I was working on that needed some dynamic grid system for the UI/Canvas. I was really struggling on how to even start and wanted to just scrap the idea altogether until someone from your discord mentioned you made this video. Very helpful and very easy to follow tutorial, thank you once again!

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

      Hey no probs! One of my first tutes, unfortunately I never finished the series as teased in this video. But a good starting point! Glad to hear you are back on track!!!

  • @lineofdeparture3584
    @lineofdeparture3584 4 года назад +4

    Exactly what I was looking for. For the love of God, please do the next Video.

  • @tas0s
    @tas0s 4 года назад +20

    Everyone: [SerializeField] private int
    Me: public int

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

      Thats the easy way out lol, just remember they're not quite the same

  • @marcelloandrade3962
    @marcelloandrade3962 8 месяцев назад

    Exactly what I was looking for, thanks for teaching this

  • @joeskis
    @joeskis 4 года назад +1

    okay.... but now how to do you get an individual tile within that grid if you want something specific to happen to just one, like change color if pressed or whatever... And what if you don't want it centered?

  • @dman-tm
    @dman-tm 4 года назад +1

    I'm stuck at the point where you Instantiate grass tile straight from your resources file. Visual Studio won't find my GameObject or the folder in which the prefab is held. does anyone know whats wrong? I've tried renaming all items and folders and scripts.. everything to match yours exactly and it still won't work. did visual studio take this out method out and replace it with something else? I can't figure this out..

    • @gurby8585
      @gurby8585 4 года назад

      I get the same thing

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

    I want to update this GridHolder object on a click of a button ie. 4*2, 5*5, 3*2 based on the parameters passed.
    For me, the code is getting executed to generate the grid but it's not updating the UI. What can be done?

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

    The final result doesn't look centered. Are you sure you need the 1/2 time offset? I think the 1/2 grid adjustment is enough.

  • @jandanczura8028
    @jandanczura8028 4 года назад

    4:02 I've got Visual Studio 2019 and Unity 2019.4 and I'm new in it. How I can do that?

    • @tijon1350
      @tijon1350 4 года назад

      after typing "for", press tab key two times

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

    Can you LINK to the next-part of this tutorial for creating a road and a player move? Can't find from "playlist" or channel search! Naming of video title may be different?

  • @ZebulonsPi
    @ZebulonsPi 5 лет назад +3

    Hi! Loved the video (subbed!), am really looking forward to a follow up on generating from a dataset, and possibly creating grids bigger than the screen, and being able to scroll around them!

    • @LostRelicGames
      @LostRelicGames  5 лет назад +2

      Hi Jason, glad it was useful. Yeah the dynamic map from dataset was the initial plan here but i got side tracked by a platformer series. will return to this soon in a more meaningful way - maybe like a top down roguelite series or something.

    • @LostRelicGames
      @LostRelicGames  5 лет назад +1

      Here is an invite to the discord if you want to talk gamedev:
      discord.gg/yeTuU53

    • @Denigrate123
      @Denigrate123 5 лет назад +1

      @@LostRelicGames Yes please! This is exactly what I'm looking for!

    • @Mukund472
      @Mukund472 4 года назад +1

      hey I want to build exactly that, did you get anything useful around it? Would be grateful for some links

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

    Is there a way make grid have Id number instead of GreenBackground(Clone)(Clone)?

  • @general_md
    @general_md 4 года назад +1

    How can I use it for my isometric 2d game?

  • @yellow4756
    @yellow4756 4 года назад +1

    is this dynamic grid also applicable on making a Building game or management game?

    • @LostRelicGames
      @LostRelicGames  4 года назад +1

      Hey mate, yea absolutely, each cell could hold data related what is on the square , building, resource etc

  • @김아영-z7w
    @김아영-z7w 2 года назад +1

    hello. Thanks for uploading a nice video. I'm a college student new to Unity. I want to apply the contents of the video you uploaded to my 3D project, will it work the same if I apply the contents to 'canvas'? I'm talking about the canvas in the UI tab. This is what I was looking for, so I asked in a comment. Thank you. I use a translator so my words may not be smooth.

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

    I am looking and I am not sure that I see a part 2 for creating multiple tiles on a grid.

  • @boomboom6410
    @boomboom6410 4 года назад +1

    YO! I was so close to finishing this tutorial but for some reason my tile wasn't readable and my "GenerateGrid" thing wasn't valid either. I'm new to the coding scene so I only know a small sliver of coding info. If anyone can help me out as to how to fix this problem that'd be great!

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

      @Noam Stein Cool, I'll try that

  • @mariellsanchez9803
    @mariellsanchez9803 4 года назад +1

    I tried adding a background and the grid is not showing. help plss! :(

    • @KatanaHSM
      @KatanaHSM 4 года назад

      Change the order layer of the background to 0

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

    how could we do this if the grid size changed randomly?

  • @thisdaulet9059
    @thisdaulet9059 5 лет назад +1

    there will be a programming in C# video?

  • @swensunyaro2185
    @swensunyaro2185 4 года назад

    How can i randomize ^the tile so if I have 5 tiles I want to be randomly mixed how could I do that?

    • @subliminalcastillo2126
      @subliminalcastillo2126 4 года назад +1

      If you want it to be completely random, you could do this:
      //Create 5 variants of the Tile prefab, each with your desired tile.
      //At the top of your script create 5 serialized GameObject variables.
      //Drag and drop your 5 tile prefabs in the inspector.
      //In the for loop:
      int randomNumber= System.Random.Next(1, 6);
      GameObject tileToInstantiate;
      //Create a switch statement...
      switch(randomNumber){
      case 1:
      tileToInstantiate = tile_prefab_1;
      break;
      case 2:
      tileToInstantiate = tile_prefab_2;
      break;
      //....etc......
      Then instantiate the tileToInstantiate variable in the for loop just like he showed in the video.

    • @swensunyaro2185
      @swensunyaro2185 4 года назад

      @@subliminalcastillo2126 Thanks!

  • @freecode.ai-
    @freecode.ai- 5 лет назад

    Hello Thanks for the tutorial. Is it possible to use button prefabs in this grid?

    • @LostRelicGames
      @LostRelicGames  5 лет назад +1

      Hey Jessie, you should be able to instantiate any type of prefeb that suits using this approach.

  • @vincesloan1672
    @vincesloan1672 4 года назад

    What's the recommended amount of pixels for a tile

  • @essouaiedameur7642
    @essouaiedameur7642 4 года назад

    this's weird i made the object scrip but it was on writing file so i went to its source and opened as VS while writing the code litterly there was 0 error even tho i made alot of mistakes there was no error detected at all

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

    Very cool. I'm leaving the like in the tutorials I'm doing.

  • @123gigaleo
    @123gigaleo 4 года назад

    Does this have any advantages over the Unity tilemap system?

    • @subliminalcastillo2126
      @subliminalcastillo2126 4 года назад

      Yes & no.
      If you are just trying to use it as a tilemap, then it's most likely a better idea to just use tilemap.
      But when you are making a system like this, it gives you the ability to extend the functionality of each tile in the grid.
      For example...
      You could implement the ability to click on each tile, and have every tile do something different.
      Or you could make it into a heatmap, where each tile stores an integer (temperature) & you could create rules for how the heat disperses.
      You could have a building system where when you click on one tile, and drag along a straight path down a row, it paves a road, etc etc.
      A good example of a game that does this is Terraria. They procedurally generate a grid of tiles that have more functionality than a standard tilemap. Whenever you click on a tile, a raycast is sent from the camera to the world position where the mouse-position is located. This starts a timer while you are holding the mouse button down on that tile. Whenever the timer finishes, that block gets destroyed, and an item gets instantiated at the same location to be able to be picked up in your inventory.
      All of that would be either impossible, or way too impractical to implement with unity tilemaps just by themselves.

  • @walney2008
    @walney2008 4 года назад

    hello, could you teach how to make a system of planting seeds and harvesting?

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

    Did you end up making a follow up to this!?!?

  • @mariellsanchez9803
    @mariellsanchez9803 4 года назад

    Is there anyway to modify the matrix or even delete it?

    • @LostRelicGames
      @LostRelicGames  4 года назад +1

      If you push the tiles into a multi-dimensional list/array you should be able to reference them through index

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

    Is there anyway to make the grid with your own object type. I have a class called Cell which holds values as well as a png sprite.

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

    Why is my grid infinite when the dimensions are 1x1?

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

    Did you ever create the dynamic map tutorial? I am interested in creating something dynamic that I could change during gameplay, though what I am planning to do will be using letter tiles rather than floor tiles.

  • @thisdaulet9059
    @thisdaulet9059 5 лет назад +1

    I can ask a question, I am a Kazakh from Kazakhstan, I wanted to know how you feel about programming and how you learn languages?

    • @LostRelicGames
      @LostRelicGames  5 лет назад

      i taught myself to program when i was young, i bought some books and practiced by making very simple games!

  • @mikay5998
    @mikay5998 5 лет назад +4

    Hey, great tutorial. I was wondering how can I change opacity of grid

    • @subliminalcastillo2126
      @subliminalcastillo2126 4 года назад

      Late to the party, but in the 2nd for loop (the one creating the columns)
      Right after you create a variable "tile" that is of type "GameObject", which is the one instantiated...
      Two simple options... You can get the current color of the sprite renderer, and create a new color from it with a different ALPHA value.
      Or if you already know the color of it, you can just set it to that.
      option 1:
      Color startingColor = tile.GetComponent().color;
      Color newColor = new Color(newColor.r, newColor.g, newColor.b, x}; //Where x is the amount of opacity you want.
      tile.GetComponent.color = newColor;
      option 2:
      Color myColor;
      tile.GetComponent().color = myColor;

    • @subliminalcastillo2126
      @subliminalcastillo2126 4 года назад

      You could also create a SerializeField at the very top of your script that exposes the color in the inspector
      [SerializeField] private Color myColor;
      And then assign it to the Tile's Sprite Renderer Component in the for loop the same way I showed above.
      It's easier to select the color in the inspector, as opposed to messing around with the color's RGB values via code.

  • @thisdaulet9059
    @thisdaulet9059 5 лет назад +1

    Your short videos are very interesting, I will look and test, it is very interesting to program a video, but I myself do not know how to program, and how learn how to program games?

    • @LostRelicGames
      @LostRelicGames  5 лет назад +1

      Hey, i will try make some very basic videos for you. You should download Unity and do some tutorials! It will take time to learn, but we all have to start as beginners

  • @AbrutissementTV
    @AbrutissementTV 4 года назад

    In 2019 have already component GRID for 2D game ... Is sad to make this when have already component and is easy for make collision, visual etc ...

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

    GREAT TUTORIAL. THANKS

  • @mr.pratik3494
    @mr.pratik3494 4 года назад

    really nice tutorial
    but how can i make it stay on the scene

  • @cromtogaming4999
    @cromtogaming4999 5 лет назад +1

    Very Good and Helpful video, man! Great job! Its a sub from me!!

    • @LostRelicGames
      @LostRelicGames  5 лет назад +1

      Thank you so much, I am glad you found it useful!

  • @toxiconflict
    @toxiconflict 5 лет назад +2

    Interesting video. What is the purpose in a dynamic grid when making a 2d game?

    • @LostRelicGames
      @LostRelicGames  5 лет назад +6

      Great question! It can be used in many types of classic-style grid based games; anything from original Zelda to top down rogue lites. This approach allows you to generate levels from a data set(or randomly with some additional logic), instead of placing everything by hand! Ill be sure to explore this in more depth in a follow up vid. Have a great day!

  • @twotime463
    @twotime463 4 года назад

    Is this for 2d platformers?

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

    dose anyone have the script i can use?

  • @burhmoment3903
    @burhmoment3903 5 лет назад

    Why is GridW negative?

  • @krzysztofpaszkiewicz1274
    @krzysztofpaszkiewicz1274 5 лет назад

    There isn't a followup?

  • @walney2008
    @walney2008 5 лет назад +1

    create a game bingo, how card bingo ?

  • @hanswurst1047
    @hanswurst1047 5 лет назад +2

    How I can get this responsive? I have many Tiles and they should scale that I can see all on the screen. Nice Vid :)

  • @Firerx97
    @Firerx97 5 лет назад +1

    Really nice video, i was searching for this exact thing!

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

  • @V.Z.69
    @V.Z.69 4 года назад +1

    Do you interact with your viewers, or just upload content and hope to get views? If you do answer comments. How could you add a TEXT object dynamically just as a tile would be added to the Stage/Scene? I come from a Flash/AS3 background with programmable layers and a Stage. It's similar, but also way different.

    • @thefreeze6023
      @thefreeze6023 3 года назад +4

      If you want someone to help you stop asserting rude things into your comments and instead ask nicely. Dear god.

  • @sabin97
    @sabin97 5 лет назад

    i need to get more familiar with unity. been postponing it for far too many years...

    • @LostRelicGames
      @LostRelicGames  5 лет назад

      Here is an invite to the discord, come hang out, talk dev, and find inspiration :)
      discord.gg/yeTuU53

  • @tonymax7503
    @tonymax7503 4 года назад +1

    Go to video to search how others implement this feature. Open it. Listen and look how author open unity and creates new project. Why? Why u do this? For bigger video time? Or u don't want cut some timing from your source video? Every who open this video he already now how to open unity and create damn project. OMG!!!! Literally 40% of whole video is regular project creation. And most important u for some reason call it "Dynamic Grid", but what is dynamic? Dynamic means this is not hardcode? Means that u can pass parameters to your grid holder? For me dynamic grid means solution which can hold resizable grid with performaly access to cell. Just time wasting

    • @seiinity
      @seiinity 4 года назад

      That's rough, buddy.

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

    thank you so much

  • @tenzenin6301
    @tenzenin6301 4 года назад

    Having a hard time finding a tutorial that covers exactly what I need:
    stackoverflow.com/questions/63426940/what-is-the-best-way-to-dynamically-generate-3d-objects-on-a-grid-in-unity

  • @user-ms9yk5ug3e
    @user-ms9yk5ug3e 5 лет назад

    great, but how can you make a character move in the grid

    • @LostRelicGames
      @LostRelicGames  5 лет назад +1

      Hey I'm planning a follow up on this soon; thinking to make it into a full game series. Enemies, random movement, collectables etc.

    • @user-ms9yk5ug3e
      @user-ms9yk5ug3e 5 лет назад

      That sound good, its very hard
      To find content of grid based games in unity

    • @LostRelicGames
      @LostRelicGames  5 лет назад +1

      @@user-ms9yk5ug3e I agreed, although several people's asked me why I would not use the new unity TileMap system. I looked at it and don't really see anyway to generate dynamic grids, or from external data, I could be wrong, but but seems like it's just for visual placement. It's this uncertainty that held me back a little from starting this dynamic grid 'rogue' style game series.

    • @LostRelicGames
      @LostRelicGames  5 лет назад +2

      @@user-ms9yk5ug3e I'm a big fan of manually creating and populating grids through these loops. It gives more control and power to developer.

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

    it`s slow, very slow. You need to use tilemaps and Grids with Tilebase. Make tutorial about it, please)

  • @klixer234
    @klixer234 4 года назад

    You should enable skippable ads :)

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

    perfect

  • @thisdaulet9059
    @thisdaulet9059 5 лет назад +1

    Nice

  • @baraasaad2366
    @baraasaad2366 5 лет назад

    ffs why it is so fucking hard to create a map ?