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
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
Can't wait for the next video. This feels like a solution which would scale nicely even for bigger games. Subscribed!
I hope you enjoy this tutorial! If you have any questions, leave them below and I'll be happy to answer.
@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
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
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?.
Exactly what I was looking for. For the love of God, please do the next Video.
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
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!!!
Exactly what I was looking for, thanks for teaching this
Very cool. I'm leaving the like in the tutorials I'm doing.
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
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
5 жыл бұрын
Here is an invite to the discord if you want to talk gamedev: discord.gg/yeTuU53
@Denigrate123
4 жыл бұрын
@@LostRelicGames Yes please! This is exactly what I'm looking for!
@Mukund472
3 жыл бұрын
hey I want to build exactly that, did you get anything useful around it? Would be grateful for some links
Very Good and Helpful video, man! Great job! Its a sub from me!!
@LostRelicGames
5 жыл бұрын
Thank you so much, I am glad you found it useful!
GREAT TUTORIAL. THANKS
Really nice video, i was searching for this exact thing!
@LostRelicGames
5 жыл бұрын
Thanks Fuego! Glad to have helped you
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?
Everyone: [SerializeField] private int Me: public int
@matchafluff
3 жыл бұрын
Thats the easy way out lol, just remember they're not quite the same
there will be a programming in C# video?
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.
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?
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?
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.
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
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
thank you so much
Hey, great tutorial. I was wondering how can I change opacity of grid
@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
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.
Is there a way make grid have Id number instead of GreenBackground(Clone)(Clone)?
What's the recommended amount of pixels for a tile
How can I use it for my isometric 2d game?
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
4 жыл бұрын
I get the same thing
hello, could you teach how to make a system of planting seeds and harvesting?
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.
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
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.
Hello Thanks for the tutorial. Is it possible to use button prefabs in this grid?
@LostRelicGames
4 жыл бұрын
Hey Jessie, you should be able to instantiate any type of prefeb that suits using this approach.
I am looking and I am not sure that I see a part 2 for creating multiple tiles on a grid.
really nice tutorial but how can i make it stay on the scene
perfect
How I can get this responsive? I have many Tiles and they should scale that I can see all on the screen. Nice Vid :)
Did you end up making a follow up to this!?!?
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
3 жыл бұрын
@Noam Stein Cool, I'll try that
how could we do this if the grid size changed randomly?
is this dynamic grid also applicable on making a Building game or management game?
@LostRelicGames
4 жыл бұрын
Hey mate, yea absolutely, each cell could hold data related what is on the square , building, resource etc
4:02 I've got Visual Studio 2019 and Unity 2019.4 and I'm new in it. How I can do that?
@tijon1350
4 жыл бұрын
after typing "for", press tab key two times
Nice
@LostRelicGames
5 жыл бұрын
Thanks Daulet, i'm glad you enjoyed it!
I tried adding a background and the grid is not showing. help plss! :(
@KatanaHSM
3 жыл бұрын
Change the order layer of the background to 0
How can i randomize ^the tile so if I have 5 tiles I want to be randomly mixed how could I do that?
@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
3 жыл бұрын
@@subliminalcastillo2126 Thanks!
Why is my grid infinite when the dimensions are 1x1?
Interesting video. What is the purpose in a dynamic grid when making a 2d game?
@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!
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 ...
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
5 жыл бұрын
i taught myself to program when i was young, i bought some books and practiced by making very simple games!
Does this have any advantages over the Unity tilemap system?
@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.
Is there anyway to modify the matrix or even delete it?
@LostRelicGames
4 жыл бұрын
If you push the tiles into a multi-dimensional list/array you should be able to reference them through index
i need to get more familiar with unity. been postponing it for far too many years...
@LostRelicGames
4 жыл бұрын
Here is an invite to the discord, come hang out, talk dev, and find inspiration :) discord.gg/yeTuU53
create a game bingo, how card bingo ?
Is this for 2d platformers?
Why is GridW negative?
There isn't a followup?
dose anyone have the script i can use?
You should enable skippable ads :)
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
it`s slow, very slow. You need to use tilemaps and Grids with Tilebase. Make tutorial about it, please)
great, but how can you make a character move in the grid
@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
5 жыл бұрын
That sound good, its very hard To find content of grid based games in unity
@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
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.
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
3 жыл бұрын
If you want someone to help you stop asserting rude things into your comments and instead ask nicely. Dear god.
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
3 жыл бұрын
That's rough, buddy.
ffs why it is so fucking hard to create a map ?