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

Ойындар

► Easily Make Platfomers in Unity - u3d.as/2eYe​
​​► Easily Make Car Games in Unity - u3d.as/1HFX
Say thanks by wishlisting my upcoming game Blood And Mead:
store.steampowered.com/app/10...
Check out my latest Devlog where I show how I saved my game from failure
• Nintendo Saved my Drea...
In this tutorial I will show howto make a dynamic grid in unity using 2d tile sprites and c#. A great starting point for other gamedev projects.
#gamedev #unity #lostrelicgames

Пікірлер: 100

  • @LostRelicGames
    @LostRelicGames5 жыл бұрын

    Hey guys! I'd love to get your feedback on the game I'm making, pls let me know what you think : kzread.info/dash/bejne/pmie0NekpL3TZ6w.html

  • @moduntilitbreaks
    @moduntilitbreaks4 жыл бұрын

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

  • @LostRelicGames
    @LostRelicGames5 жыл бұрын

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

  • @MyAfricanCats

    @MyAfricanCats

    4 жыл бұрын

    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

    3 жыл бұрын

    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

    3 жыл бұрын

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

  • @lineofdeparture3584
    @lineofdeparture35844 жыл бұрын

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

  • @MyPing0
    @MyPing02 жыл бұрын

    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 жыл бұрын

    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!!!

  • @marcelloandrade3962
    @marcelloandrade39623 ай бұрын

    Exactly what I was looking for, thanks for teaching this

  • @renatojrrdc
    @renatojrrdc3 жыл бұрын

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

  • @ZebulonsPi
    @ZebulonsPi5 жыл бұрын

    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 жыл бұрын

    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 жыл бұрын

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

  • @Denigrate123

    @Denigrate123

    4 жыл бұрын

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

  • @Mukund472

    @Mukund472

    3 жыл бұрын

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

  • @cromtogaming4999
    @cromtogaming49995 жыл бұрын

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

  • @LostRelicGames

    @LostRelicGames

    5 жыл бұрын

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

  • @DBernardOfficial
    @DBernardOfficial Жыл бұрын

    GREAT TUTORIAL. THANKS

  • @Firerx97
    @Firerx975 жыл бұрын

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

  • @LostRelicGames

    @LostRelicGames

    5 жыл бұрын

    Thanks Fuego! Glad to have helped you

  • @joeskis
    @joeskis4 жыл бұрын

    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?

  • @tas0s
    @tas0s3 жыл бұрын

    Everyone: [SerializeField] private int Me: public int

  • @matchafluff

    @matchafluff

    3 жыл бұрын

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

  • @thisdaulet9059
    @thisdaulet90595 жыл бұрын

    there will be a programming in C# video?

  • @WolfRose11
    @WolfRose113 жыл бұрын

    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.

  • @vrushalibhosale3061
    @vrushalibhosale30612 жыл бұрын

    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?

  • @ChannelJB
    @ChannelJB3 жыл бұрын

    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?

  • @user-ze9mt5wf9w
    @user-ze9mt5wf9w2 жыл бұрын

    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.

  • @thisdaulet9059
    @thisdaulet90595 жыл бұрын

    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 жыл бұрын

    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

  • @haruesan7245
    @haruesan72452 жыл бұрын

    thank you so much

  • @mikay5998
    @mikay59985 жыл бұрын

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

  • @subliminalcastillo2126

    @subliminalcastillo2126

    3 жыл бұрын

    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

    3 жыл бұрын

    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.

  • @canadianmodder7403
    @canadianmodder74032 жыл бұрын

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

  • @vincesloan1672
    @vincesloan16724 жыл бұрын

    What's the recommended amount of pixels for a tile

  • @general_md
    @general_md3 жыл бұрын

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

  • @dmansor2
    @dmansor24 жыл бұрын

    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

  • @walney2008
    @walney20084 жыл бұрын

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

  • @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.

  • @essouaiedameur7642
    @essouaiedameur76423 жыл бұрын

    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

  • @rithwikvaidun9992
    @rithwikvaidun99923 жыл бұрын

    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.

  • @freecode.ai-
    @freecode.ai-4 жыл бұрын

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

  • @LostRelicGames

    @LostRelicGames

    4 жыл бұрын

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

  • @N3rdBoundGaming
    @N3rdBoundGaming2 жыл бұрын

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

  • @mr.pratik3494
    @mr.pratik34944 жыл бұрын

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

  • @nghialuong6857
    @nghialuong6857 Жыл бұрын

    perfect

  • @hanswurst1047
    @hanswurst10475 жыл бұрын

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

  • @ryanwilson6758
    @ryanwilson67583 жыл бұрын

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

  • @boomboom6410
    @boomboom64103 жыл бұрын

    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

  • @BarsSaybak
    @BarsSaybak2 жыл бұрын

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

  • @yellow4756
    @yellow47564 жыл бұрын

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

  • @LostRelicGames

    @LostRelicGames

    4 жыл бұрын

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

  • @jandanczura8028
    @jandanczura80284 жыл бұрын

    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

  • @thisdaulet9059
    @thisdaulet90595 жыл бұрын

    Nice

  • @LostRelicGames

    @LostRelicGames

    5 жыл бұрын

    Thanks Daulet, i'm glad you enjoyed it!

  • @mariellsanchez9803
    @mariellsanchez98034 жыл бұрын

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

  • @KatanaHSM

    @KatanaHSM

    3 жыл бұрын

    Change the order layer of the background to 0

  • @swensunyaro2185
    @swensunyaro21854 жыл бұрын

    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

    3 жыл бұрын

    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

    3 жыл бұрын

    @@subliminalcastillo2126 Thanks!

  • @coffee_bean__
    @coffee_bean__3 жыл бұрын

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

  • @toxiconflict
    @toxiconflict5 жыл бұрын

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

  • @LostRelicGames

    @LostRelicGames

    5 жыл бұрын

    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!

  • @AbrutissementTV
    @AbrutissementTV4 жыл бұрын

    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 ...

  • @thisdaulet9059
    @thisdaulet90595 жыл бұрын

    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!

  • @123gigaleo
    @123gigaleo4 жыл бұрын

    Does this have any advantages over the Unity tilemap system?

  • @subliminalcastillo2126

    @subliminalcastillo2126

    3 жыл бұрын

    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.

  • @mariellsanchez9803
    @mariellsanchez98034 жыл бұрын

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

  • @LostRelicGames

    @LostRelicGames

    4 жыл бұрын

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

  • @darkvenommusic
    @darkvenommusic11 ай бұрын

  • @sabin97
    @sabin974 жыл бұрын

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

  • @LostRelicGames

    @LostRelicGames

    4 жыл бұрын

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

  • @walney2008
    @walney20085 жыл бұрын

    create a game bingo, how card bingo ?

  • @twotime463
    @twotime4634 жыл бұрын

    Is this for 2d platformers?

  • @burhmoment3903
    @burhmoment39035 жыл бұрын

    Why is GridW negative?

  • @krzysztofpaszkiewicz1274
    @krzysztofpaszkiewicz12744 жыл бұрын

    There isn't a followup?

  • @austinjones9387
    @austinjones9387 Жыл бұрын

    dose anyone have the script i can use?

  • @klixer234
    @klixer2344 жыл бұрын

    You should enable skippable ads :)

  • @tenzenin6301
    @tenzenin63014 жыл бұрын

    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

  • @westparezal
    @westparezal3 жыл бұрын

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

  • @user-ms9yk5ug3e
    @user-ms9yk5ug3e5 жыл бұрын

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

  • @LostRelicGames

    @LostRelicGames

    5 жыл бұрын

    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 жыл бұрын

    @@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 жыл бұрын

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

  • @V.Z.69
    @V.Z.693 жыл бұрын

    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 жыл бұрын

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

  • @tonymax7503
    @tonymax75033 жыл бұрын

    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

    3 жыл бұрын

    That's rough, buddy.

  • @baraasaad2366
    @baraasaad23664 жыл бұрын

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

Келесі