Awesome Grid Building System! (City Builder, RTS, Factorio, Survival)

✅ Get the Project files and Utilities at unitycodemonkey.com/video.php...
🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Games unitycodemonkey.com/gamebundle
✅ In this Unity Tutorial, let's make an Awesome Grid Building System!
This is a super versatile system, can be used for anything like making a City-Builder, RTS, Factory Automation game, Survival, etc.
In fact, I'm currently hard at work making a fun Factorio-like with a bunch of buildings, items and conveyor belts and it's all based upon this system.
Grid System in Unity (How to make it and where to use it)
• Grid System in Unity (...
Simple Building System in Unity (Freeform Building Placement)
• Simple Building System...
Awesome Builder-Defender Game! (Complete Course)
• Awesome Builder-Defend...
Simple Buildings - Cartoon City - Asset Pack
assetstore.unity.com/packages...
How to Modify the Game Object Transform Pivot
• How to modify the Game...
Make your Games Designer Friendly! (Scriptable Objects)
• What are Scriptable Ob...
🌍 Get Code Monkey on Steam!
👍 Interactive Tutorials, Complete Games and More!
✅ store.steampowered.com/app/12...
If you have any questions post them in the comments and I'll do my best to answer them.
🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
See you next time!
📍 Support on Patreon / unitycodemonkey
🤖 Join the Community Discord / discord
🎮 Grab the Game Bundle at unitycodemonkey.com/gameBundl...
📝 Get the Code Monkey Utilities at unitycodemonkey.com/utils.php
how to make a city builder, how to make a survival game, how to make a strategy game, how to make a rts, unity city builder, unity rts
#unitytutorial #unity3d #unity2d #unity​ #gamedev​ #indiegame​ #gamedevelopment #madewithunity​ #indiedev​
--------------------------------------------------------------------
Hello and Welcome!
I'm your Code Monkey and here you will learn everything about Game Development in Unity using C#.
I've been developing games for several years with 8 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
I do Unity Tutorials on just about every topic, Unity Tutorials for Beginners and Unity Tutorials for Advanced users.
You can see my games at www.endlessloopstudios.com
--------------------------------------------------------------------
- Other great Unity channels:
Brackeys - / brackeys
Dani - / @danidev
Jabrils - / @jabrils
BlackthornProd - / @blackthornprod
Sykoo - / sykootv
Jason Weimann - / @unity3dcollege
Jonas Tyroller - / @jonastyroller
--------------------------------------------------------------------
- Website: unitycodemonkey.com/
- Twitter: / unitycodemonkey
- Steam: store.steampowered.com/develo...

Пікірлер: 633

  • @CodeMonkeyUnity
    @CodeMonkeyUnity3 жыл бұрын

    🌐 Have you found the videos Helpful and Valuable? ❤️ Get my Courses unitycodemonkey.com/courses or my Steam Games 🎮 unitycodemonkey.com/gamebundle 💬 Here's a really awesome Building System that you can use to build anything, doesn't have to be actual Buildings. You can use it in a RTS, Factory game, Survival, etc. In fact I'm currently working on a Factory Automation mini-game where I'm using this system as a base for placing down all kinds of objects! It's super versatile so definitely look forward to many more videos using this system as a base! What do you imagine you can do with it?

  • @kyleevans4830

    @kyleevans4830

    3 жыл бұрын

    Hi CodeMonkey! I'm trying to sign up on your website but when I click the validate email link it tells me 'Invalid validate link.'. Might want to check that out! Thanks for the awesome tutorials. You're the best!

  • @dieweltentdecker5878

    @dieweltentdecker5878

    3 жыл бұрын

    I dont find the building sound in the Unity package?

  • @ludvigerdmann3352

    @ludvigerdmann3352

    2 жыл бұрын

    My unity protect says that it cant find the GridBuildingSystem3D file

  • @peterbelanger4094

    @peterbelanger4094

    2 жыл бұрын

    (Using Unity 2020.3.12f1).....Started clean, new project, tried to import the unitypackage, and there are 57 errors. Am I missing some dependencies?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    @@peterbelanger4094 What errors? Make sure you're using URP and Cinemachine

  • @youtuber9991
    @youtuber99912 жыл бұрын

    I appreciate the videos, but they're extremely difficult to follow and implement due to: 1) Code structure changes between videos with no explanation 2) No explanation on how they're used in a particular scene (I realized that earlier videos depended on a 2D scene, later ones a 3D scene that's not compatible with earlier setups) 3) The source code links require registering for your website (annoying), and once downloaded the file is a unity bundle that then must be imported into unity to read, and also it's just one big cluster of random files and projects. The file I was looking for is a completely different name and structure as well from what's covered in the videos. Would be far better to just place source files in github and to not deviate from the format or naming at all.

  • @skyswimsky1994

    @skyswimsky1994

    2 жыл бұрын

    I kinda agree with all of this. The grid things just kind-of grew over time, and later tutorials even just go about the "approach" rather than "1:1 follow the code" thing. Which I think is fine to a degree. But following along/checking out the source code is extremely annoying. I'd love to: 1) Redo the things aimed at more experienced users (like having the TGridObject fire an event when the value changes and have the grid be able to subscribe to it to loosen the coupling etc.) 2) Provide a GitHub with multiple branches being multiple-steps for people to check out themselves with clear-cut foldernames for ease of access I know making a lot of money is important to you and there's this whole youtube buzzwords and keeping videos short thingamajic going on. But if that is an issue, a multi-part series would be maybe cool too. Or just livestream it all and hire a dedicated editor for it? But bottom line is, I'd love for the codes and all to really just be on a public repo for people to check out with some clear-cut instructions. Said 'instructions' could be as simple as just making dedicated/'calculated' commits, each representing a new feature. That way one could compare files and what changed easily and also follow your new style of "tutorials" more easily. In fact I think I like that easy enough that I'll try commenting/suggesting it on a newer video for visibilities sake. As for 'converting' it from 2d to 3d, it's really just a change of the coordinates, or alternatively this video: kzread.info/dash/bejne/Za6stsugmq3YYpc.html

  • @truth8483

    @truth8483

    2 жыл бұрын

    Agreed. Really frustrated with how the format of the grid system tutorial series evolved. Impossible to follow along and the source files are just a big file dump. A compact github repository with only the absolutely necessary files with consistent naming would be huge and immensely helpful. Please fix this codemonkey. Thank you.

  • @bigadingm5908

    @bigadingm5908

    2 жыл бұрын

    to go from 2D to 3D just go to the grid script and on getvalue(for the world pos) change from vector3 (x,y) to vector 3 (x,0,y)

  • @bigadingm5908

    @bigadingm5908

    2 жыл бұрын

    but you are right for example the Mouse3D he dont have it in the utils so i have to do it myself but still now i know exatly how to do it

  • @carroll6

    @carroll6

    2 жыл бұрын

    me too, it's hard to follow. Goes so fast.

  • @ObsessiveGames
    @ObsessiveGames3 жыл бұрын

    Wow, this is just amazing, looking forward to see the factorio style to finish up as I have a full game design that I want to make that needs this logic. Thank you !

  • @diskerus
    @diskerus3 жыл бұрын

    It's fantastic... that's what I was searching so long. Thank you, Code Monkey. You deserve millions subscribers as Brackeys

  • @CodemasterJamal
    @CodemasterJamal3 жыл бұрын

    Dude, this is exactly what I was looking for for my Homepage system. Thanks a lot. This pretty much refines what I was trying to make.

  • @alaslipknot
    @alaslipknot3 жыл бұрын

    Am really digging those helper functions that fixes the rotation and offsets based on predetermined values, before watching this video, i would have probably done it the hard way and tried to come up with "real time" solution that do some shenanigan calculations, when a simple enum and a couple of Switch-case could solve it, thanks man!

  • @leonn5148
    @leonn51483 жыл бұрын

    Oh thank you so much!!!! I was struggling to find something similar to this for weeks. Cheers!!

  • @jean-michel.houbre
    @jean-michel.houbre3 жыл бұрын

    Great video, very clear and exciting. This system looks powerful indeed. I will also be interested in your implementation of a factory system. Thank you.

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

    This is probably one of the most useful tutorials for starting a cool game system ever! THANK YOU! :)

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    I'm glad you liked it! Thanks!

  • @honzakusy
    @honzakusy3 жыл бұрын

    Great video! It really helped me with the implementation of my game! Nice work 👏

  • @Fragler01
    @Fragler012 жыл бұрын

    I am a complete beginner when it comes to coding in C#. I am already familiar with some of the basics (ifs, fors, constructors and so on) however, it completely blew my mind how awesomly well this code is written, and how reuseable everything is really a great example of clean code. Thank you for the awesome tutorials mate. I have a lot to learn from you :)

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Thanks! If you want to improve your programming skills I highly recommend the book Code Complete. If you read through the whole thing you will improve your skills 10x!

  • @Fragler01

    @Fragler01

    2 жыл бұрын

    @@CodeMonkeyUnity thanks for the advice, definiatly gonna get that, however I am not a big bookworm. I tried to find online courses, coursera is what I am expriencing with. My only problem with online curses are either they are too advanced and I don’t understand a single world, or opposingly just the basics.

  • @sundarakrishnann8242
    @sundarakrishnann82423 жыл бұрын

    Glad to see that many of your new videos are getting better views!😜

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Thanks! Yeah it seems people have enjoyed the last few videos!

  • @toprogress
    @toprogress7 ай бұрын

    Sweet and quick tutorial, perfect to acquire experience in coding. Thanks for the knowledge!

  • @Gredran
    @Gredran3 жыл бұрын

    I know that the principle is probably the same no matter what, but whether it’s Unity, Unreal, Godot, etc, I am so amazed about all of the games ANYONE can make for free if you take the time to learn, iterate and understand. It feels so good what I thought was magic to learn exactly how it is, and it amazes me that many things in game design(well movies in general but I feel even more for games) are just a combination of illusions that come to make something great :) Thanks for all these videos!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Yup that is indeed an excellent thing. 10 years ago it was all magic and would take tons of knowledge to make a simple game but nowadays with all these engines anyone can make a game, it's awesome!

  • @dartutorials7859
    @dartutorials78593 жыл бұрын

    NIce finally i can build my own city 👍👍 I might upload the city that I built with this tut

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

    Game development has become so easy now. I started with unity and then got the curiosity to learn how to make games from scratch with c++ and it made me realize how easy it has become over the years. The code to render things in 2d takes a lot of code and time to write all those codes. But at the end when you run the program it brings tears of joy to eyes.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Yup the tools that exist nowadays make things so much easier, you need to be a genius to make your own engine, but anyone can open Unity create a simple script and hit play

  • @TomMcDonaldGames
    @TomMcDonaldGames2 жыл бұрын

    Great Tutorial. Thanks for putting this together..

  • @user-jt7bf2fo5m
    @user-jt7bf2fo5m3 жыл бұрын

    Hey Code Monkey, Great tutorial here! I really respect the stuff you do here on youtube, and even going and replying to comments on each of the videos, something I never see youtubers do. Keep up the great stuff! I was having some issues with making the visual ghost thing work in my 2d game, if you take video suggestions, I would love to see a video talking about how that all works for 2d and 3d games!

  • @ajogar
    @ajogar3 жыл бұрын

    you don't know how long i've been looking for this

  • @dererzherzog
    @dererzherzog3 жыл бұрын

    Yoy're the best! Thank you so much for sharing your knowledge with us!

  • @Setanta93
    @Setanta933 жыл бұрын

    Looking forward to your next game, I've 100%-ed almost every game you've released!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    That's awesome to hear, I'm glad you liked them! Thanks!

  • @izzet8635
    @izzet86353 жыл бұрын

    OMG SERIOUSLY, THIS WAS EXACTLY WHAT I NEEDED AND IT JUST CAME OUT. sorry for yelling xD

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    I'M GLAD YOU'RE EXCITED! Thanks!

  • @GhostSlayerYT

    @GhostSlayerYT

    3 жыл бұрын

    @@CodeMonkeyUnity is there a basic tutorial of making a game? cause I started learning a week or two ago

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    @@GhostSlayerYT I covered Unity Basics here kzread.info/dash/bejne/d2p1lrmvo6fLfKg.html And C# Basics here kzread.info/dash/bejne/e3qV27Oin6qdYaQ.html

  • @GhostSlayerYT

    @GhostSlayerYT

    3 жыл бұрын

    @@CodeMonkeyUnity oh thanks And c# means the scripting part right?

  • @alxoseal517

    @alxoseal517

    3 жыл бұрын

    @@GhostSlayerYT Yes

  • @Rivera-D
    @Rivera-D3 жыл бұрын

    Wahhhhhh awesome, this is what i need. Thanks 🔥❤️

  • @Syvies
    @Syvies9 ай бұрын

    This series of tutorial is really amazing, thank you so much for doing it. It is so good, I managed to reproduce everything in Godot and it works just like yours!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    9 ай бұрын

    Nice! Best of luck with your game!

  • @BimzyDev
    @BimzyDev3 жыл бұрын

    Good stuff, thanks for the tutorial! 😆

  • @donkeymonkey4435
    @donkeymonkey44353 жыл бұрын

    Seriously , Tears are coming out of my Eyes ( I am Happy like Anything !!! ) i searched for a Video like this 2 months back but there were none ( Even Brackeys didnt teach this ) You now gave A Tutorial that is Interested by all Game Devs like me!! ( I can see that , just from the Comments ) I Dont know , who the Hell , Disliked this Video

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    I'm glad you found the video helpful!

  • @oguzhanozcelik8466
    @oguzhanozcelik84663 жыл бұрын

    Awesome tutorials!!! Keep up the good work!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Thanks!

  • @guridoraccoon6375
    @guridoraccoon63753 жыл бұрын

    omg ive been building my grid system these days. perfect!

  • @leventebalog8696

    @leventebalog8696

    3 жыл бұрын

    Timing for the win

  • @zaimatsu
    @zaimatsu3 жыл бұрын

    You can write extension method for Dir enum for clarity. That way you can write "dir = dir.Next();". Great video!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    That's a great tip! I definitely should use extension methods more often

  • @ssj3mohan
    @ssj3mohan3 жыл бұрын

    I love your tutorials .

  • @HugoMesquitaO
    @HugoMesquitaO3 жыл бұрын

    Amazing work!!!

  • @leonardo6631
    @leonardo66313 жыл бұрын

    Amazing video 😁

  • @UmeshRajaramKandekar
    @UmeshRajaramKandekar3 жыл бұрын

    Awesome Sir 🔥🔥

  • @tiwrun
    @tiwrun3 жыл бұрын

    Helps a lot thanks

  • @vmmi8215
    @vmmi82153 жыл бұрын

    Love this video so much 👍👍

  • @tweetymr
    @tweetymr3 жыл бұрын

    You saved my live! I tried to extend your previous version to do exactly what you describe here but couldn't get it to work. Thank you so much :-)

  • @tweetymr

    @tweetymr

    3 жыл бұрын

    Btw: is there a way to modify the grid so I can create a level in the editor with it?

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

    Hi! Really great video! How would you handle L shaped buildings? Maybe an idea for the next video :)

  • @unohhhjjdd6716
    @unohhhjjdd67162 жыл бұрын

    Hi Code Monkey, I have found very few decent tutorials on grids in Unity, and yours is great, but I have a question. I'm developing a first person farming game, and I need to plant some vegetables on the field. So I'd like to plant them on a grid system like yours using a raycast, but I've been overwhelmed by the number of your tutorials on the grid system. Could you suggest me which ones I need to watch?

  • @MikoGot
    @MikoGot3 жыл бұрын

    amazing work!

  • @echo9dev
    @echo9dev3 жыл бұрын

    Just signed up for your website, nice work. :) 😃

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Nice! Enjoy learning from the project files!

  • @easyanton7952
    @easyanton79523 жыл бұрын

    Perfect! Thank you very much! You quickly showed that you make a game, with conveyor belts. Will there be a tutorial with them?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    I am working on a more showcase video rather than a step-by-step tutorial but yes I will mention how the belts work

  • @aditkumar4644
    @aditkumar46443 жыл бұрын

    I literally needed it like right now thanks code monkey

  • @acez28
    @acez283 ай бұрын

    3 years later...thank you Code monkey... you don't know the length of good you have done 👍

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 ай бұрын

    heh I'm glad the video helped you! I also love how some tutorials are somewhat timeless

  • @AstralZenithal
    @AstralZenithal3 жыл бұрын

    Cool tutorial!

  • @myownthoughts969
    @myownthoughts9693 жыл бұрын

    I Have to slow the video down to try to keep up with you but my efforts are use less..lol I’m. Not able to understand what’s happening and how it’s happening... but I’m learning and this is by far one of the best videos I have found to try go threw the code on... thanks..

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    You can also download the project files to inspect the source code better, combine that with watching the video and it will be easier to understand

  • @_CloudyBunny
    @_CloudyBunny3 жыл бұрын

    Much appreciated !

  • @LivingEd
    @LivingEd3 жыл бұрын

    Keep going bro 😀

  • @subliminalcastillo2126
    @subliminalcastillo21263 жыл бұрын

    Code Monkey coming in clutch with the tutorials everyone wants.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Thanks! I try to give the people what they want!

  • @Grinwa

    @Grinwa

    2 жыл бұрын

    @@CodeMonkeyUnity yea u r awesome tnks a lot

  • @Surenian
    @Surenian9 ай бұрын

    Hello, so I have some advice for those using unity version 2022+ just incase you having some issues, 1 -- when downloading CM's assets for any of his videos if you already have script's with the same naming structures both Unity and Visual studio are going to throw a fit, simple fix is to use /* above the using statement's and */ at the very last line of the CM script's, this clear's most of the issues in the project for the script's and still allows you to use them as reference when solving issues, 2 - if you import the scene it can some times have issues that I haven't found a fix for, best to not import that and simply rebuild the scene normally doesn't take very long, also don't import anything that say's URP or Setting's for some reason this causes issue's I'm not sure why Better to just import URP into your project or, start a project already setup for URP, 3- best way to add your own prefab's to replace pink/purple issue with visual's is to use the same structure as CM, by adding a prefab with the logic, then having the script logic instantiate the visual of your choice as a child of the parent(what the logic script is attached too), then changing what's needed in your script's to fix any other issues that are still persistent, as for an easy ghost prefab can just have the material set to 50% or so transparency and then have it set back with code after the prefab as been placed/Instantiated(this worked for me, might try it urself), 4 don't forget to also download and import CM's util's, or build some of your own with the same naming structure to prevent having to change a ton of code.. if u have other issues after doing this I apologize as I'm still new to a lot of this as well and not sure how to help, Sorry this was a mouth full! Ps. CM in the part of this video where you check to see if a building is occupying multiple point's on the grid, is there any advice you can give if I wanted to check if a unique oddly shaped object where to be rotated and which part's of the grid where at the closes co-ordinance and then make the grid with a value of Range(x etc.) or a bool of T/F change the underlying grid values, I've been trying some ideas on my own to get this to work with no success so far, any advice would be helpful. With that said, Thank you for your video's as they have been a great source of learning both programing and game development as well as clean coding technics. I look forward to continuing to watch and learn, Keep it up your doing Great! (I'm using unity 2022 3d URP project setup and have had no issues after fixing the above Hope this helps!)

  • @PurplySkye
    @PurplySkye2 жыл бұрын

    Hey, I'm having the problem of needing to save the grid layout, but it can't convert the type array to a class array. How do I save the grid position?

  • @odatas
    @odatas2 жыл бұрын

    Amazingly good tutorial. Just a question. When you implement the destruction why not just store the vector2 list used when instantiating. On destruction you just access the list from the transform you allready have and delet the object and then clear the transoform. I find the solution you provide much more complicated. So essentially instead of reverse enginering the Vector2 List just Store it.

  • @Updates_
    @Updates_3 жыл бұрын

    Thanks for this

  • @oatcube3961
    @oatcube39613 жыл бұрын

    I created a system like this for my game except it doesn't use the grid system like that. It basically just rounds the vector coordinates from Camera.ScreenToWorldPoint to full values (1.0f, 2.0f etc) to "snap it" into a grid. I'm also using tilemap colliders to check the area beneath (some buildings can only be constructed on specific ground area and they can't be built on walls or other buildings. I'm also using raycasting to check if the area is a legal building space. I'm about to finish all my sprites for the buildings of my game. Just one more to go, but I had to check this video first to see how you are doing the building placement ':D

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Yup that's pretty much the same method I used on the Freeform building system with some snapping on top kzread.info/dash/bejne/d6SBqLGef7CvnrA.html It's a great simple system

  • @DakotaRileyMedia
    @DakotaRileyMedia3 жыл бұрын

    Hey, I love this tutorial and definitely could use it in a project in the future. But, I have a suggestion for a future video that could expand upon the grid system. I wonder if there is a way to take the grid and use it to generate terrain and buildings on a map. I’m thinking of a system like ACNH, where an island is a general shape but that the game would randomly generate all the terrain features on a grid inside the blinds if the island so each time you played you got a new island layout (which can be customized if desired later in the game). I’m sure it’s probably a huge ask, but I think it would be a great addition onto the series of grid related tutorials you have.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Using this for a terrain system would definitely be interesting. Usually random generation is made more with Perlin noise but you could apply this system in the end and do something interesting with it. I'll look into it, thanks!

  • @1lsgaming27
    @1lsgaming273 жыл бұрын

    Thanks!👍🏾👍🏾

  • 3 жыл бұрын

    Hi, thanks for all your content! It helps me a lot - not only with Unity, but also with the "game dev thinking"! :) I have a question related to this. What will be the approach, when the terrain will be not flat? It will be easy to implement the different terrain heights? Thanks for hint :)

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    The simplest approach would be to keep the underlying Grid flat and only snap the placed objects to the terrain. But if you need the Grid to match with the terrain perfectly by area then that's much more complicated, not exactly sure how you could do that, probably need to take the Terrain mesh and make a simplified Grid mesh while keeping the rough terrain shape.

  • @amberlewis012
    @amberlewis0123 жыл бұрын

    Holy chicken wings this tutorial was uploaded at the perfect time!

  • @StigDesign
    @StigDesign3 жыл бұрын

    This is Really Awesome :D Next how to save every thing and also Load? This gives me idea of Track Bulder inside my racing game, sort of like parkEditor in Thps 2-4, or TrackMania :D if only i had money to hire you :D

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Yup you could combine this with the Save system I made previously kzread.info/dash/bejne/aKmBqKeGXdHHoKg.html and you'd be able to save the grid with all the buildings and even share the save file with friends.

  • @StigDesign

    @StigDesign

    3 жыл бұрын

    @@CodeMonkeyUnity oh i see That`s cool :D Awesome, i didnt knwo you had made a save&load video, ir i had forgotten it hehe :)

  • @Sakros
    @Sakros2 жыл бұрын

    Hey, great video as always! But I do have a question.. how should I go about implementing non-rectangular buildings? Think of sort of tetris-shapes.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Instead of just storing a width and height for hte building you would need to store the shape, possibly with a bool array with true for occupied positions

  • @Pro1ooPlayer
    @Pro1ooPlayer3 жыл бұрын

    Thanks! Now it would be cool to see a tutorial on how to make a shop on a scriptable object like in the game civilization or clash of clans

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

    Very nice video! Could you make a follow up and explain how you could make a more-dimensional grid, for example for multi story houses? That would be very nice and awesome.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    You can make multiple Grid Systems for each height level, that's what I did for my house building system unitycodemonkey.com/video.php?v=Cdcn6uK9gPo

  • @selmansavas586
    @selmansavas5863 жыл бұрын

    Really came in clutch for my RTS game! Only issue that i have, how to invalidate positions on the grid where the terrain is too steep bu build on. Gotta figure it out somehow. Thanks for the tutorial!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Thanks! You could do a Raycast to sample multiple points within a grid position and check the total height difference between them.

  • @selmansavas586

    @selmansavas586

    3 жыл бұрын

    @@CodeMonkeyUnity That is an awesome idea! Will definetely check it out, thanks a lot

  • @shivamprajapati6839
    @shivamprajapati68393 жыл бұрын

    5 star content!!!

  • @GameReleaseENG
    @GameReleaseENG3 жыл бұрын

    This looks amazing! Is that system also recommended when you wanna create a grid with a lot of tiles(like over 90k tiles?) like similar to rimworld.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    You would need a system to manage multiple grids instead of having a single huge giant grid but yes this system can work for that.

  • @PyRubier
    @PyRubier3 жыл бұрын

    I have a question. Has anyone ever told you that you are a FUCKING BOSS? :D

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

    Have been enjoying your videos, they make better sense than the other bunch I've watched on 3d grids. I do have a question though, how could one convert this to a third-person interaction instead of the mouse? Looking st your Petfect Aim video it had me wondering on this function

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    I made a House Building System in Third Person here unitycodemonkey.com/video.php?v=gkCBCCKeais Basically works the same, do a Raycast to get the world position and convert that to a grid position

  • @CyberStudios

    @CyberStudios

    Жыл бұрын

    @@CodeMonkeyUnity thank you so much!!! That makes sense. I actually forgot about raycasts in that situation - THANKS for sharing your knowledge

  • @sandeeproy3126
    @sandeeproy31262 жыл бұрын

    Hey what about saving the buildings state and position for persistency something similar to clash of clans style game , will the NoSQL (mongo db) will be suitable for such job or should I use relational MySQL

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    The database you use is separate from the data itself, you can use any data format with any database. I covered saving and loading with JSON here kzread.info/dash/bejne/aKmBqKeGXdHHoKg.html You can use that for the data format and store it in any database you want.

  • @itsmeolee6710
    @itsmeolee67102 жыл бұрын

    How do you handle the object placement preview logic as displayed in the intro of this video? It shows a preview of the object you are going to place, with lerping as you move the cursor along the tiles? Smooth rotations etc? Thanks

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Check the grid position under the mouse, tell the ghost to go towards that position and just smoothly lerp the value kzread.info/dash/bejne/nHWClKuoh8e2qrA.html

  • @itsmeolee6710

    @itsmeolee6710

    2 жыл бұрын

    @@CodeMonkeyUnity Thank you :)

  • @ignallacay
    @ignallacay2 жыл бұрын

    Great video/series. Really helpful! Having some trouble with grid out-of-bounds cases, both in object placement and for the ghost visual. Trying some things without success. Hopefully I'll get it working correctly eventually. In the first, I get a null reference error for object reference not being set on an instance of the object. I've seen some comments about it but can't get it working right. In the second, the ghost visual is visible and its transform follows the mouse outside the grid. I need to disable it when outside, and re-enable it when inside the grid. Not sure if the same happens in the video's implementation since the topic isn't covered a lot in it.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    To avoid null refs the simple solution is to always validate the position, just a simple check if x,y is > 0,0 and I don't remember how I made it in this demo but yup that's one option, let it follow hte mouse exactly if there's no grid position underneath or leave the ghost on the last valid grid position. Although if you were to use this in a complete game then chances are the play area is much bigger than what I used in the demo so going out of bounds is less of an issue.

  • @hakansoydan4832
    @hakansoydan48329 ай бұрын

    I am trying to run this project with a URP build however the animations of the buildings and the buildings themselves are not showing up what could be the casuse of this. I can only see a blue parcel with the name of the building shown on the tile map.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    9 ай бұрын

    Yes correct, I did not make those assets so I cannot include them in the project files, all the logic is there but not the visual assets. There's a link in the description for the asset pack that I used

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

    Where does the GridXZ come from? I watched the tutorials but I didn't see it anywhere.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    I made it offscreen but it's 99% the same as the regular Grid system that I made in previous videos on this playlist kzread.info/head/PLzDRvYVwl53uhO8yhqxcyjDImRjO9W722 The difference is really just swapping the XY logic for XZ logic unitycodemonkey.com/video.php?v=3zxTigjJr24

  • @solecito69
    @solecito692 жыл бұрын

    How to do Save system in this project. :( The grid system not work in my Custon Save :(

  • @user-bs8cu2nu1c
    @user-bs8cu2nu1c7 ай бұрын

    Hi, thanks for the video. where can I find only the utils and the scripts that you dont show on the video? I dont want the entire project but on most of the script i cant use because I miss parts like the scriptble object

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    7 ай бұрын

    You can download the project, import it to a separate project and then take only the parts you want onto your own project Or just the utilities are here unitycodemonkey.com/utils.php

  • @starsquad9814
    @starsquad98143 жыл бұрын

    I am currently making a game using the new input system and I used your grid system code and now the problem is when I click the mouse position is not increasing the number but now my players are so it increases the number based on my character not my mouse. Does anyone have a solution to this, thank you.

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

    Hi CodeMonkey, very good video by the way but even having understood the subject as a whole, I can't figure out how to make sure that I already have a structure placed on the grid and make it possible to move the grid during that the game is running and not just create it at startup? Your content is always so refreshing and a source of motivation, good luck for the next :)

  • @Mikael._

    @Mikael._

    Жыл бұрын

    Quite late answer but... His grid system have a Vector for the origin position, if i remember well (there is couple years i don't use unity anymore) i used to change the grid origin to move it if needed.

  • @syamz
    @syamz2 жыл бұрын

    Hello, i find it difficult to find the boundary of grid in script. I would like to deselect object when the mouse outside the grid. If anyone find the solution, kindly share here

  • @teemuleppa3347
    @teemuleppa33473 жыл бұрын

    Thanks for the video. Any chance of seeing creating in-game level editor tutorial sometime?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    This could definitely be used as a level editor, combine it with a Save Load system kzread.info/dash/bejne/aKmBqKeGXdHHoKg.html and you can even easily share levels.

  • @zbyszekkiebasa906
    @zbyszekkiebasa9062 жыл бұрын

    Fix for those who are getting null references for the CanBuild() check for multi-grid buildings along the edges of the grid and couldn't fix it themselves: bool canBuild = true; foreach (Vector2Int gridPosition in gridPositionList) { //this is the fix if (grid.GetGridObject(gridPosition.x, gridPosition.y) != null) { if (!grid.GetGridObject(gridPosition.x, gridPosition.y).CanBuild()) { canBuild = false; break; } } else { canBuild = false; break; } } all you have to do is to check if grid tile returns GirdObject, and if it doesn't then you can't build there

  • @buckyBitBoy

    @buckyBitBoy

    Жыл бұрын

    I had this problem with the original source code his provided. Your solution fix the problem. But there is another issue, when the ghost cursor is outside of the grid, when I place the object, it places at nearest cell, even if I clicked outside it. Did you fixed it too?

  • @heyitsapogee
    @heyitsapogee2 жыл бұрын

    Hey CodeMonkey! Loving this video series so far. I think I'm missing something, but how are you able to "spawn/instantiate" what looks like building prefabs using "Transform"- more specifically, at 4:04. Thanks!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Transform and GameObject are pretty interchangeable, you can spawn the entire prefab with either reference. Every Transform is always attached to a Game Object, and every Game Object always has a Transform component.

  • @heyitsapogee

    @heyitsapogee

    2 жыл бұрын

    @@CodeMonkeyUnity Interesting, I've not seen this done yet! Thanks for the explanation :)

  • @TheGhost_179
    @TheGhost_1793 жыл бұрын

    Any chance of a grid fog of war tutorial? (Like the aoe2 where you can see building you discover but not units ) Thanks for all your tutorials

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    That would be interesting, I'd definitely love to do some more RTS tutorials

  • @Berndr

    @Berndr

    3 жыл бұрын

    why not just use 2 layers for that, one that render things you want to see and other one to exclude units unless in sight

  • @roshanthapa1297
    @roshanthapa12973 жыл бұрын

    How about adding something in ground of grid like (green for correct and red for not appropriate) making sure that the user can distinguish where to place like in other many games. Just my opinion 😅

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Yup that's definitely an awesome addition, I've already made a Tilemap based on this Grid System so it would be super easy to add that on top of this kzread.info/dash/bejne/mXhpp7OypJq8gM4.html

  • @agonyzx
    @agonyzx2 күн бұрын

    Hello CodeMonkey, I followed your tutorial until you placed your first building at around 5:30. It did not work for me as expected, because the building was always placed in the first cell. After quick debugging I found out that the Raycast always returned a Vector3 zero, so that explains why the building was always placed in the first cell. I don't see you using any colliders on your cell, but as soon as i added colliders to my cells it started working. So I am wondering how did you make it work without using colliders on your cells? Could you please explain that? Thank you! :)

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

    How would I be able to change the color of the Ghost building Visual to something like Red for example when i cant build into that gridObject?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Just modify the material override

  • @idance_div
    @idance_div8 ай бұрын

    Hey sir , please make a video on how to upgrade buildings for a given time and when time is completed we can see the new upgraded building

  • @evanhay6032
    @evanhay60322 жыл бұрын

    These videos are awesome, can't find stuff that is this specific to my use case anywhere else. I am wondering, how would I go about "reading" the grid -- like finding the nameString of a SO that's on a particular grid location, from another script?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    You get the grid object on that position, then you can do whatever you want with it. The building placement logic is reading the grid in order to find out if a certain position is empty before placing. To get it from another script, it depends on how your code is set up but you just need some public accessor

  • @evanhay6032

    @evanhay6032

    2 жыл бұрын

    ​@@CodeMonkeyUnity this worked, thank you!

  • @elturkocharro4106
    @elturkocharro41063 жыл бұрын

    Hi!! any idea why as soon I remove the ": MonoBehaviour" from the Public Class Grid I'm getting the 'Grid' is missing the class attribute 'ExtensionOfNativeClass' and I can't be able to attach into a new GameObject? Thanks in advance!!!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    There is already a built-in Unity class named "Grid", my own Grid class uses Generics so Grid and Grid are two different classes.

  • @gregorykl2317
    @gregorykl23173 жыл бұрын

    HI! Can you help me?) Where did you take a C# script GridXZ? I watched video about making grids, but there wasn't it.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    It's the same thing just modified to work on XZ instead of XY I talked about 2D to 3D conversion here kzread.info/dash/bejne/Za6stsugmq3YYpc.html

  • @Zinisco
    @Zinisco2 жыл бұрын

    This is awesome! One question. If I wanted to convert this into a system that would place buildings in random spots on the grid. How would I implement that?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    You know the grid width and height, so just do a Random.Range(); to get a random x,z and use that

  • @danamarie5655
    @danamarie56552 жыл бұрын

    Hi Code Monkey, you are awesome! You're helping me a lot with your videos! I would like to ask, if I wanted to implement snap in this environment, to be able to move the builded objects, how could I proceed? Maybe did you make a video about it? Thanks in advance!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Snapping how? The system is already snapping to the grid positions

  • @danamarie5655

    @danamarie5655

    2 жыл бұрын

    ​@@CodeMonkeyUnity I mean, having the possibility of drag existing buildings with mouse and move them on another gridposition instead of destroying them and recreating in the position we want. Also, I wanted to ask how can I check if the building that I want to create is going out of bounds of the grid, handling the exception it throws (NullReferenceException: Object reference not set to an instance of an object). Thank you! I really appreciate your work!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    ​@@danamarie5655 That's going to depend on how your buildings work. If there's a lot of setup involved then destroying and recreating is the easiest method. In order to move them you need to move the prefab, set up the building again with the new position, and remove/readd on the Grid system. If you know the size of the building you can test if its going outside the bounds or not, if the position is over the width or height then don't move it.

  • @danamarie5655

    @danamarie5655

    2 жыл бұрын

    @@CodeMonkeyUnity Thank you for reply! I think I will follow the destroy and recreate method. I would like to destroy the building as you do, then set the placedObjectTypeSO = the building I just destroyed, to have it immediately ready to replace with the visual of that prefab. How can I do this? Obviously I cannot simply do placedObjectTypeSO = placedObject, because they are two different types...

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

    Thanks again for a great video. One thing I would like to understand is how you size your tiles to match with the grid? For example, if I have a path that I am trying to lay out, how are they sized properly for a grid that is larger than the unity unit?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    You just scale the visuals/prefabs or modify the grid cellSize to match what you have in the visuals/prefabs

  • @MarkMcArthey

    @MarkMcArthey

    Жыл бұрын

    @@CodeMonkeyUnity thanks for the quick reply! Scaling the visuals up led to blurry images but I may just need better images. Also when creating the backgrounds for paths and such it was hard to place them properly without the help of the grid in the scene

  • @MarkMcArthey

    @MarkMcArthey

    Жыл бұрын

    @@CodeMonkeyUnity Ah that completely makes sense now that I've had a chance to check it out. Once I added the 2D Tilemap I simply scaled it to match the grid size (10 in my case), and the tiles from the palette naturally lined up without any fuss. Thanks so much! And I purchased your Builder course today too given how helpful you've been! Thanks!

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

    The type or namespace name 'GridXZ' could not be found (are you missing a using directive or an assembly reference?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Did you download the project files? That's not a built-in class, it's something I made in a previous video unitycodemonkey.com/search.php?q=grid+system

  • @epochofgenesis-official6608
    @epochofgenesis-official66083 жыл бұрын

    Ok, so im curious, if im using a 3d environment how do i make each grid tile elevate if say for instance, i have a portion of the map that is higher than the rest of the terrain? im building an isometric 2.5d type game. and i have elevated platforms for hills. also is there a way i could use the terrain data to generate the grid map to follow the terrain? so it procedurally elevates a specific tile according to the map data?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Following the terrain is a bit complex but doable, I made a House System with multiple preset levels kzread.info/dash/bejne/dZiX0Jiue5zNgNI.html

  • @epochofgenesis-official6608

    @epochofgenesis-official6608

    3 жыл бұрын

    @@CodeMonkeyUnity cool thanks. I checked it out. It uses a list of grids and elevates each grid, switching between them. Seems straight forward enough it should work.

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

    Hi sir, I got error problem in Mouse3D.css in line 22. Its said object reference not set to an instance of an object. where should I put this script to? Thank you

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Just make sure there's an object in the scene with that script unitycodemonkey.com/video.php?v=0jTPKz3ga4w

  • @maow9240
    @maow92402 жыл бұрын

    for some reason when i place a building it only places on the x part of the grid and doesn't go on the z part. this occurred after around 6:30 when implementing the instantiation on the grid and not just anywhere you click

  • @maow9240

    @maow9240

    2 жыл бұрын

    nevermind i found the issue. it was with the gridxz script as i was working from the first video one the playlist making the grid system and when altering the class to the gridz i missed one single ".y" when changing them to lol

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

    I have a question: How would you manage to move a selector based on the mouse position inside the grid AND make the selector move in Y-position when already an object is set on a grid position? I managed to move the selector using the BuildingGhost script but what is your suggestion to make the selector also work in different heights on Y, so you can build up levels on top of each other in 3D?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    On my House Building System I just made a clear button input to change which grid is active unitycodemonkey.com/video.php?v=Cdcn6uK9gPo unitycodemonkey.com/video.php?v=gkCBCCKeais If you want something more intuitive you can perhaps do it based on zoom distance or something like that to automatically select which level to build on.

  • @ChrisNoeth

    @ChrisNoeth

    Жыл бұрын

    @@CodeMonkeyUnity Thank you very much!

  • @AndyLukito
    @AndyLukito3 жыл бұрын

    Awesome!

  • @SorataGamedev

    @SorataGamedev

    3 жыл бұрын

    hello dude :3

  • @SorataGamedev

    @SorataGamedev

    3 жыл бұрын

    @@age9502 hi :v

  • @PoolInPajamas
    @PoolInPajamas2 жыл бұрын

    can this be used for xcom like strategy like you did in your other video that im having a bit of a trouble with?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Yup kzread.info/dash/bejne/Za6stsugmq3YYpc.html

  • @RodAires
    @RodAires3 жыл бұрын

    Hi Code Monkey, I think the "ghost" part of the video is missing... I switched the prefabs and the alpha/transparency/ghost is not working

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Are you using the renderer object from the files? That's what handles the visual

  • @shaurya543
    @shaurya5433 жыл бұрын

    Could you tell how random struturey could be build

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

    Hello! Since I didn't see it in the playlist and was very confused about the newly-introduced GridXZ class, may I suggest you add the video about converting 2D systems to 3D into the playlist? ♥

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    It's just a swap from XY to XZ so I didn't make a dedicated video on that, I talked about it briefly here unitycodemonkey.com/video.php?v=3zxTigjJr24

  • @Mikes-Code

    @Mikes-Code

    Жыл бұрын

    Hey, ive been struggling with this as well. If you download the project files, you can actually find the entire GridXZ class code over there. I'm working on a 3D base building system, for my tutorial. So I came here to get inspiration.

  • @lunasylphhh

    @lunasylphhh

    Жыл бұрын

    @@Mikes-Code thank you I have been struggling the same issue.