Тёмный

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

Code Monkey
Подписаться 532 тыс.
Просмотров 235 тыс.
50% 1

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

Опубликовано:

 

16 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 637   
@CodeMonkeyUnity
@CodeMonkeyUnity 3 года назад
🌐 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
@youtuber9991 2 года назад
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: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-3zxTigjJr24.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
@ObsessiveGames 3 года назад
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
@diskerus 3 года назад
It's fantastic... that's what I was searching so long. Thank you, Code Monkey. You deserve millions subscribers as Brackeys
@alaslipknot
@alaslipknot 3 года назад
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!
@CodemasterJamal
@CodemasterJamal 3 года назад
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.
@Gredran
@Gredran 3 года назад
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!
@leonn5148
@leonn5148 3 года назад
Oh thank you so much!!!! I was struggling to find something similar to this for weeks. Cheers!!
@ChrisNoeth
@ChrisNoeth 2 года назад
This is probably one of the most useful tutorials for starting a cool game system ever! THANK YOU! :)
@CodeMonkeyUnity
@CodeMonkeyUnity 2 года назад
I'm glad you liked it! Thanks!
@dartutorials7859
@dartutorials7859 3 года назад
NIce finally i can build my own city 👍👍 I might upload the city that I built with this tut
@jean-michel.houbre
@jean-michel.houbre 3 года назад
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.
@sundarakrishnann8242
@sundarakrishnann8242 3 года назад
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!
@Fragler01
@Fragler01 2 года назад
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.
@izzet8635
@izzet8635 3 года назад
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 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-E6A4WvsDeLE.html And C# Basics here ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-IFayQioG71A.html
@GhostSlayerYT
@GhostSlayerYT 3 года назад
@@CodeMonkeyUnity oh thanks And c# means the scripting part right?
@alxoseal517
@alxoseal517 3 года назад
@@GhostSlayerYT Yes
@honzakusy
@honzakusy 3 года назад
Great video! It really helped me with the implementation of my game! Nice work 👏
@toprogress
@toprogress 9 месяцев назад
Sweet and quick tutorial, perfect to acquire experience in coding. Thanks for the knowledge!
@ajogar
@ajogar 3 года назад
you don't know how long i've been looking for this
@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
@TomMcDonaldGames 2 года назад
Great Tutorial. Thanks for putting this together..
@guridoraccoon6375
@guridoraccoon6375 3 года назад
omg ive been building my grid system these days. perfect!
@leventebalog8696
@leventebalog8696 3 года назад
Timing for the win
@BimzyDev
@BimzyDev 3 года назад
Good stuff, thanks for the tutorial! 😆
@Rivera-D
@Rivera-D 3 года назад
Wahhhhhh awesome, this is what i need. Thanks 🔥❤️
@UmeshRajaramKandekar
@UmeshRajaramKandekar 3 года назад
Awesome Sir 🔥🔥
@leonardo6631
@leonardo6631 3 года назад
Amazing video 😁
@Setanta93
@Setanta93 3 года назад
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!
@dererzherzog
@dererzherzog 3 года назад
Yoy're the best! Thank you so much for sharing your knowledge with us!
@HugoMesquitaO
@HugoMesquitaO 3 года назад
Amazing work!!!
@Syvies
@Syvies 11 месяцев назад
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 11 месяцев назад
Nice! Best of luck with your game!
@oguzhanozcelik8466
@oguzhanozcelik8466 3 года назад
Awesome tutorials!!! Keep up the good work!
@CodeMonkeyUnity
@CodeMonkeyUnity 3 года назад
Thanks!
@vmmi8215
@vmmi8215 3 года назад
Love this video so much 👍👍
@MikoGot
@MikoGot 3 года назад
amazing work!
@ssj3mohan
@ssj3mohan 3 года назад
I love your tutorials .
@tiwrun
@tiwrun 3 года назад
Helps a lot thanks
@donkeymonkey4435
@donkeymonkey4435 3 года назад
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!
@_CloudyBunny
@_CloudyBunny 3 года назад
Much appreciated !
@tweetymr
@tweetymr 3 года назад
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?
@AstralZenithal
@AstralZenithal 3 года назад
Cool tutorial!
@user-jt7bf2fo5m
@user-jt7bf2fo5m 3 года назад
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!
@aditkumar4644
@aditkumar4644 3 года назад
I literally needed it like right now thanks code monkey
@easyanton7952
@easyanton7952 3 года назад
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
@echo9dev
@echo9dev 3 года назад
Just signed up for your website, nice work. :) 😃
@CodeMonkeyUnity
@CodeMonkeyUnity 3 года назад
Nice! Enjoy learning from the project files!
@Updates_
@Updates_ 3 года назад
Thanks for this
@LivingEd
@LivingEd 3 года назад
Keep going bro 😀
@omyb
@omyb Год назад
Hi! Really great video! How would you handle L shaped buildings? Maybe an idea for the next video :)
@1lsgaming27
@1lsgaming27 3 года назад
Thanks!👍🏾👍🏾
@unohhhjjdd6716
@unohhhjjdd6716 3 года назад
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?
@Sakros
@Sakros 2 года назад
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
@PyRubier
@PyRubier 3 года назад
I have a question. Has anyone ever told you that you are a FUCKING BOSS? :D
@zaimatsu
@zaimatsu 3 года назад
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
@AndyLukito
@AndyLukito 3 года назад
Awesome!
@SorataGamedev
@SorataGamedev 3 года назад
hello dude :3
@SorataGamedev
@SorataGamedev 3 года назад
@@age9502 hi :v
@acez28
@acez28 5 месяцев назад
3 years later...thank you Code monkey... you don't know the length of good you have done 👍
@CodeMonkeyUnity
@CodeMonkeyUnity 5 месяцев назад
heh I'm glad the video helped you! I also love how some tutorials are somewhat timeless
@myownthoughts969
@myownthoughts969 3 года назад
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
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.
@shivamprajapati6839
@shivamprajapati6839 3 года назад
5 star content!!!
@amberlewis012
@amberlewis012 3 года назад
Holy chicken wings this tutorial was uploaded at the perfect time!
@selmansavas586
@selmansavas586 3 года назад
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
@GameReleaseENG
@GameReleaseENG 3 года назад
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.
@odatas
@odatas 2 года назад
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.
@DakotaRileyMedia
@DakotaRileyMedia 3 года назад
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!
@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
@StigDesign
@StigDesign 3 года назад
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 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-6uMFEM-napE.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 :)
@Pro1ooPlayer
@Pro1ooPlayer 3 года назад
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
@teemuleppa3347
@teemuleppa3347 3 года назад
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 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-6uMFEM-napE.html and you can even easily share levels.
@lukaspaver
@lukaspaver 4 дня назад
By any chance, do you have a starting point tip on how to move the grid while playing the game? Like in the Update() method? If not, I'm gonna try to figure it out myself somehow. Thanks anyway for the great grid system, you're such a help.
@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
@Zinisco
@Zinisco 2 года назад
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
@ignallacay
@ignallacay 2 года назад
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 < width,height 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.
@alexania
@alexania 9 месяцев назад
Hello! Thank you so much for this video, it was easy to follow and gave me a good starting point. I really like the post-processing you've done in the video, do you perhaps have a video on how to achieve that effect? (I attempted to download the project files to check but for some reason I'm just getting an error saying "Failed to download file!"
@alexania
@alexania 9 месяцев назад
Nevermind! Tried again on my home PC and it worked fine. Thanks so much for all your work.
@CodeMonkeyUnity
@CodeMonkeyUnity 9 месяцев назад
It's been a long time since I made this but for the most part it's just adding a bit of Saturation, a tiny bit of Bloom and some Screen Space Ambient Occlusion
@PurplySkye
@PurplySkye 2 года назад
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?
@sandeeproy3126
@sandeeproy3126 3 года назад
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 3 года назад
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 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-6uMFEM-napE.html You can use that for the data format and store it in any database you want.
@oatcube3961
@oatcube3961 3 года назад
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 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-EpMFOeOMInM.html It's a great simple system
@user-bs8cu2nu1c
@user-bs8cu2nu1c 9 месяцев назад
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 9 месяцев назад
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
@funkynormalcat988
@funkynormalcat988 Год назад
what would you prefer? Input system in player class, in grid system class or in a dedicated class?
@CodeMonkeyUnity
@CodeMonkeyUnity Год назад
Not sure I understand the question but usually the input system should be as separate from everything else as possible. Usually I make a GameInput class that handles with whatever Input system I'm using and then exposes some functions which the player class can hook onto
@idance_div
@idance_div 10 месяцев назад
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
@TheGhost_179
@TheGhost_179 3 года назад
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
@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.
@krizttyxd
@krizttyxd 2 года назад
Great Tutorial! Can someone explain how to do If i want to pick up the building when click again
@CodeMonkeyUnity
@CodeMonkeyUnity 2 года назад
Same logic as the demolish but grab the object instead of demolishing. I covered some simple "move" action in my Grid Inventory System ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-fxaDBE71UHA.html
@subliminalcastillo2126
@subliminalcastillo2126 3 года назад
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 3 года назад
@@CodeMonkeyUnity yea u r awesome tnks a lot
@panasonicdiet3691
@panasonicdiet3691 3 года назад
Sick
@evanhay6032
@evanhay6032 2 года назад
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!
@shaurya543
@shaurya543 3 года назад
Could you tell how random struturey could be build
@roshanthapa1297
@roshanthapa1297 3 года назад
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 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-gD5EQyt7VPk.html
@danamarie5655
@danamarie5655 2 года назад
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...
@heyitsapogee
@heyitsapogee 2 года назад
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 :)
@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!
@ruekkart
@ruekkart 3 года назад
Hi, thanks for the video. What could be the best way to build an infinite grid?
@CodeMonkeyUnity
@CodeMonkeyUnity 3 года назад
Procedurally generate more Grids as you need them, for example as the player approaches the edge of you last grid, spawn a new one
@hakansoydan4832
@hakansoydan4832 10 месяцев назад
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 10 месяцев назад
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
@ignallacay
@ignallacay 2 года назад
Hey CodeMonkey, thanks a bunch for the tutorial. I was able to successfully modify and integrate the Grid System for my current project. Would it be possible to get some help on how to delete a grid once I'm done with it?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 года назад
The grid isn't a game object, it's just a regular C# class, so if you remove all references to it then the garbage collector will clean it up
@Pandahero-ce9fi
@Pandahero-ce9fi 3 года назад
is there any chance that we get a conveyor tutorial that goes along with this?
@Crankpie
@Crankpie 3 года назад
I'm waiting too !
@CodeMonkeyUnity
@CodeMonkeyUnity 3 года назад
I am working on that Factory game and, while not a full tutorial, I will definitely mention how the conveyor belts work
@axl2858
@axl2858 3 года назад
​@@CodeMonkeyUnity I hope that's a type of project that you could share it's source code
@Berndr
@Berndr 3 года назад
Hi , amazing tutorial, How would I check what was placed in neighborhood, for example let say I have a building that gets bonus if it is placed next to a particular building, How would I when placing it down check all neighboring positions,and get data of what is if anything at all placed in all those neighboring positions such as up , down , left and right... thank you in advance
@CodeMonkeyUnity
@CodeMonkeyUnity 3 года назад
You know the grid position you want to use, so just ask the grid for whats on (x-1, y); (x+1, y), etc
@solecito69
@solecito69 2 года назад
How to do Save system in this project. :( The grid system not work in my Custon Save :(
@starsquad9814
@starsquad9814 3 года назад
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.
@Surenian
@Surenian 11 месяцев назад
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!)
@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.
@franciscojaviergraciasanti18
@franciscojaviergraciasanti18 2 года назад
Render Objects doesn't exist in the current project files. How is it call now?
@yellow4756
@yellow4756 3 года назад
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
@syamz
@syamz 2 года назад
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
@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 ru-vid.com/group/PLzDRvYVwl53uhO8yhqxcyjDImRjO9W722 The difference is really just swapping the XY logic for XZ logic unitycodemonkey.com/video.php?v=3zxTigjJr24
@ChrisNoeth
@ChrisNoeth Месяц назад
Can you please tell me if you have a video where the BuildingGhost.cs file is described in detail?
@CodeMonkeyUnity
@CodeMonkeyUnity Месяц назад
I believe it should be included in the project files for this video Although it's really just following the mouse position, and cycling through GetComponentsInChildren(); to set theh ghost material
@RodAires
@RodAires 3 года назад
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
Далее
I Made a Factory Game in 20 HOURS!
18:16
Просмотров 126 тыс.
Steam EXPERT teaches you Game Marketing for SUCCESS!
52:22
Creating a City Builder | Prototype Series
5:03
Просмотров 121 тыс.
Coding Adventure: Portals
16:06
Просмотров 1,3 млн
Building a Camera Controller for a Strategy Game
17:48
Просмотров 191 тыс.