Grid System in Unity (Heatmap, Pathfinding, Building Area)

✅ Get the Project files and Utilities at cmonkey.co/gridsystem
🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses
Let's make a Grid System that we can use to split our World into various Grid Cells.
Then we can use that to make a Heatmap or a Pathfinding Map with avoid/desire areas or a Building Grid System.
Complete Grid System in Unity Playlist
• Grid System in Unity (...
Powerful Generics Added! Grid System in Unity!
• Powerful Generics Adde...
Learn Unity in 17 MINUTES!
• Learn Unity in 17 MINU...
Learn C# BASICS in 10 MINUTES!
• Learn C# BASICS in 10 ...
• C# Basics to Advanced
Battle Royale Tycoon on Steam
store.steampowered.com/app/85...
Make Awesome Effects with Meshes in Unity | How to make a Mesh
• How to make a Mesh in ...
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!
🤖 Join the Community Discord / discord
📦 Grab the game bundle at unitycodemonkey.com/gameBundl...
📝 Get the Code Monkey Utilities at unitycodemonkey.com/utils.php
#unitytutorial #unity3d #unity2d
--------------------------------------------------------------------
Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.
I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
You can see my games at www.endlessloopstudios.com
--------------------------------------------------------------------
- Website: unitycodemonkey.com/
- Twitter: / unitycodemonkey
- Facebook: / unitycodemonkey

Пікірлер: 1 100

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

    Here's a great class to serve as a base for you to make some really awesome systems like a Heatmap, Pathfinding, Building, etc. Stay tuned for the upcoming Heatmap video and see Grid Maps in action all over the place in Battle Royale Tycoon store.steampowered.com/app/851930/Battle_Royale_Tycoon/

  • @MalikenGD

    @MalikenGD

    4 жыл бұрын

    So next video is Heatmap right? Then what's after that? Do you plan to show it used in a pathfinding setup or will you move onto the next topic? Thanks!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    ​@@MalikenGD Yup the next video is covering a Heatmap. Pathfinding is definitely something I want to cover but its a pretty complex topic so that's why I haven't had the time to do it yet. Maybe using this video as a base will make it easier.

  • @Kurock1000

    @Kurock1000

    4 жыл бұрын

    I can’t wait for a pathfinding one, it’s such a can of worms topic and you do a great job making those approachable.

  • @dreamer7939

    @dreamer7939

    2 жыл бұрын

    is it a 3d game or a 2d game

  • @madscience6283

    @madscience6283

    3 күн бұрын

    It's funny. 4 years later and copilot is auto-filling your code as I type. The impact you must have made for your work to be so widespread it gets sucked into an AI brain. Neato

  • @WesleyOverdijk
    @WesleyOverdijk3 жыл бұрын

    I find the sped up keyboard sound very satisfying to listen to

  • @zacharystanaford5466

    @zacharystanaford5466

    3 жыл бұрын

    I'm not gonna lie, I thought he just typed like a god, lol.

  • @jonathanboiragee3347

    @jonathanboiragee3347

    3 жыл бұрын

    how do I make this in 3d?

  • @rickyspanish4792

    @rickyspanish4792

    3 жыл бұрын

    code monkey ASMR!

  • @thomasharvey2980

    @thomasharvey2980

    2 жыл бұрын

    @@jonathanboiragee3347 I have the same question

  • @jlgaming9997

    @jlgaming9997

    2 жыл бұрын

    @@thomasharvey2980 in the vector3 get world pos change it to: private Vector3 GetWorldPosition(int x,int z, int y) { return new Vector3(x, z, y) * cellSize; } and change the GetWorldPosition in the utilsclass line to (x, 0, y) thr u go hope it helps

  • @haydenk589
    @haydenk5893 жыл бұрын

    16:55 if only the value in the middle of the screen changes, change your camera from "perspective" to "orthographic" in the inspector of the camera. Thank you for the tutorial, really helpful!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Yes 2D and 3D have different methods for grabbing the mouse position kzread.info/dash/bejne/Yp6Isq2zY8rHZNo.html

  • @ludoremstudios

    @ludoremstudios

    2 жыл бұрын

    Thank you! I thought there was something wrong with my code.

  • @maow9240

    @maow9240

    2 жыл бұрын

    thank you very much

  • @baguingi5589

    @baguingi5589

    2 жыл бұрын

    Thank you!, I spent a lot of lost time thinking something was wrong with my code

  • @noamriahi6437

    @noamriahi6437

    2 жыл бұрын

    Thank you for the help!

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

    Thank you so much for your tutorials, Monkey. Ever since Brackeys went dark, I've sort of been lacking direction and motivation for game development, but you've given those things back to me, my dude. What a gamer. Much love.

  • @kaheichan6228
    @kaheichan62284 жыл бұрын

    Holy you're a life saver, I couldn't find a tile systems after the changes to gameobject codes

  • @sadiqabbaszade4789
    @sadiqabbaszade47894 жыл бұрын

    This is like the beginning of a new topic for me - Grid system. THanks for the tutorial!

  • @zombievirals
    @zombievirals2 жыл бұрын

    Big help on a "city builder" style game I'm working on, or not to mention anything I do involving grids from now on. Thanks a million!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Yup very useful for CityBuilder/Management games, I've used some form of this system in all my Tycoon games.

  • @zishiwu7757
    @zishiwu77573 жыл бұрын

    If anyone is having problems implementing the EventHandler OnGridValueChanged from the end of the this video, check out 3:37 of the cool heatmap video in the series, lines 55 - 57 of the code. For this video, I implemented 22:19 lines 9 - 10, and 22:23 line 73, but I kept getting a null value for OnGridValueChanged. After implementing 3:37, lines 55 - 57 from the cool heatmap video, OnGridValueChanged got updated to a non-null value.

  • @StevePaceS
    @StevePaceS3 жыл бұрын

    Enjoying your tutorials, thanks, very helpful. I especially enjoy that you include some testing here and there to see things working out; that helps with understanding and makes the tutorial more enjoyable. Well done and thanks!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Thanks! I try hard to test the logic constantly so it's more clear what each piece of code does.

  • @maximejacob704
    @maximejacob7043 жыл бұрын

    Quick note for what you mentioned about returning a struct around 14:30: In C#, you may also return an anonymous tuple from methods. public (int, int) GetXY(Vector3 worldPosition) or public (int x, int y) GetXY(Vector3 worldPosition) would return such a Tuple. In the first case, you can access individual values with value.Item1 and value.Item2, in the second case with value.x and value.y.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Yup that's right, Tuples are a recent addition to C# so it's not something I've used a lot yet but they can indeed be very useful!

  • @icosmohedron
    @icosmohedron3 жыл бұрын

    Thank you so much I can now actually finish that level editor I wanted to make for players to use! :)

  • @jugibur2117
    @jugibur21174 жыл бұрын

    Thanks for your effort, helped me a lot to start!

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

    Awesome tutorial! I was just about to comment how it can be improved by making the Grid generic, but jokes on me, you already have that covered in another video. There are tons of good tutorials out there, but many fall apart once you try to go beyond the basic implementation of the tutorial. Your tutorials really show that you got a deep understanding of programming and your code is easily expandable. Keep up the good work, you are a blessing for the Unity community! Much love.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Thanks for the kind words! I'm glad you found the videos helpful!

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

    Even after 3 years this is still a great tutorial. It really helped me a lot, thanks.

  • @artjom5617

    @artjom5617

    Жыл бұрын

    its not like... code is outdated after 3 years..

  • @troyna77

    @troyna77

    Жыл бұрын

    @@artjom5617 if there is a possibility, some corporation somewhere will try to make you buy/subscribe to their "code" on a monthly basis.

  • @baguingi5589
    @baguingi55892 жыл бұрын

    Thanks for the tutorial man, I was looking for an aproach to fix something related to my work, and by chance this also solves a problem I've been having with a game I have wanted to make for a long time.

  • @pamhs368
    @pamhs3684 жыл бұрын

    I purchased your game bundle, and I'm sure my son will LOVE THEM! Who knows, even old me might like them! I usually play casual games. :)

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Awesome, thanks! I hope you and your son enjoy the games!

  • @skelhain
    @skelhain4 жыл бұрын

    Simply awesome! Working my way through all these great vids -> grid, heatmap, generics to the latest ecs pathfinding video, in hope I can integrate some of this into my 3D project... I'm already a little scared of the DOTS specific stuff.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Awesome! Keep learning!

  • @skelhain

    @skelhain

    4 жыл бұрын

    @@CodeMonkeyUnity I promise, if you keep making high quality tutorials!

  • @luisromero-mf4gs

    @luisromero-mf4gs

    2 жыл бұрын

    @@skelhain hey bro im trying to add this to 3d using the x,z plane y=0 but when use the setvalue need to get the mouseworldposition always return the same point and is the position of the camera

  • @lukehughes6943
    @lukehughes69432 жыл бұрын

    Null Reference Exception issue: If you're having issues with Null Reference Exception when changing the value of the grid elements, try checking your test script to see if your start function is "Grid grid = new Grid(4,2,10f);" if it is, delete that first Grid and leave it as "grid = new Grid(4,2,10f);" this fixed it for me as I hadn't noticed him delete it.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Yup, if you add the type "Grid" then you are making a local variable instead of assigning the member variable so the member variable stays as null.

  • @bane9109

    @bane9109

    Жыл бұрын

    Thank you so much for this tip, i was stuck trying to figure this out for a whole day.

  • @priv4te486

    @priv4te486

    Жыл бұрын

    Thanks a lot

  • @marularch

    @marularch

    Жыл бұрын

    OMG I was so annoyed by this, and couldn't figure out what the problem was at 16:50 . Thanks for fixing the issue, this should be pinned to top.

  • @Sissorman123456789

    @Sissorman123456789

    Жыл бұрын

    @lukehughes6943 I hope you have a fantastic day sir

  • @tsuaeghakihas469
    @tsuaeghakihas4693 жыл бұрын

    love your vids! I appreciate all you do! personally I find the Sped up footage of you writing code to be a little frustrating as I like to follow along as you write code and I have to pause to keep up. just stating my opinion. even so, please know I do appreciate all of this ! thank you, thank you. can't wait to learn more!

  • @Francisco-Gutierrez
    @Francisco-Gutierrez3 жыл бұрын

    Thanks, Im new to unity and was trying to build a classic snake game, this is what I need to start

  • @lolownq
    @lolownq4 жыл бұрын

    I managed to turn this into a grid that works with the Isometric Z as Y tilemap that tracks elevation levels. And could expand it to keep track of tiles that extend way beyond the elevation level. Thank you for a tutorial on this awesome "tool".

  • @ez4novi

    @ez4novi

    4 жыл бұрын

    How did you draw it to be isometric?

  • @lolownq

    @lolownq

    4 жыл бұрын

    @@ez4novi I will post the code on github ( github.com/dutchalphaa/Grid2DIsometric/tree/master ). I basically took all of the world position coordinates and put them through a mathmatical function that changed them into isometric coordinates and took the isometric world position coordinates into normal coordinates. There is also a method for going through every layer of the function and deciding where the top layer is EDIT: added the link: github.com/dutchalphaa/Grid2DIsometric/tree/master

  • @ez4novi

    @ez4novi

    4 жыл бұрын

    @@lolownq Thanks for sharing though, but I finally made it after hours of searching about isometric grid, you are right its just about the coordinates, I manage it using X: (x - y) Y: (x + y) in world position, here's my screenshot with implementation of pathfinding prnt.sc/r8m9a5, My head got burned btw after this ;)

  • @lolownq

    @lolownq

    4 жыл бұрын

    @@ez4novi thats grand, figuring it out on your own is way more rewarding. that being said for the people still looking for the grid implementation it can be found over on this link: github.com/dutchalphaa/Grid2DIsometric/tree/master

  • @xyhc-cnc

    @xyhc-cnc

    3 жыл бұрын

    @@lolownq Thanks! This is a life saver!

  • @BlueGooGames
    @BlueGooGames4 жыл бұрын

    Just what I needed, thanks again Code Monkey, you’re making Space Chef better one tutorial at a time :)

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    I'm glad to hear it! Best of luck with your game!

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

    Thank you so much! This helps me a lot with my on going thesis for college!

  • @MaxAndersonFilms
    @MaxAndersonFilms4 жыл бұрын

    Thanks for the awesome tutorials! Besides all the great info, I love when you say, "Yep, there you go." XD. Thanks again!

  • @m4dsci3nt1st4

    @m4dsci3nt1st4

    3 жыл бұрын

    love your devlogs

  • @MasterBroNetwork
    @MasterBroNetwork4 жыл бұрын

    Incredible, just simply incredible.

  • @yinttalmaixyond7661
    @yinttalmaixyond76614 жыл бұрын

    Great work! Hope we can see the tutorials on how to make rimworld-like games in the future. :)

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Yup that would definitely be one possible application. Currently working on making a Tilemap and then use it to make a Mining and Building System like Terraria

  • @yinttalmaixyond7661

    @yinttalmaixyond7661

    4 жыл бұрын

    @@CodeMonkeyUnity That's great! I am also trying to develop games like this... Thank you for the nice work

  • @nikolajovanovic3638
    @nikolajovanovic36383 жыл бұрын

    You’re programming is soo clean.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Thanks! Writing good clean code is very important to me!

  • @Roadkill601
    @Roadkill6018 ай бұрын

    Thank you for building this. I went through it last week and came out with a grid map. I would like to have understood more on the basics of how to use it. I wanted to simply turn a grid tile clicked a solid color, your heat map sort of got be started but seems like more than I need. Anyway Thanks again I really enjoying learning from your videos.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    8 ай бұрын

    I'm glad you found it helpful! For various use cases you can watch my Grid Building System to make something like Simcity unitycodemonkey.com/video.php?v=dulosHPl82A Or a pathfinding system unitycodemonkey.com/video.php?v=alU04hvz6L4 Or for a more guided step by step, a very similar grid is created from scratch in my Turn Based Strategy course unitycodemonkey.com/video.php?v=QDr_pjzedv0

  • @LordTalismond
    @LordTalismond4 жыл бұрын

    Can you do a tutorial like this for a Hex shaped grid?

  • @JosephWright-zq9hl
    @JosephWright-zq9hl Жыл бұрын

    If you are having issues where you keep getting the camera transform position from GetMouseWorldPosition it may be because your camera is set to perspective. I was having this issue and the way I fixed it was by setting the camera to orthographic although you could also use a raycast to a plane on the grid's z axis if you want to keep the camera as perspective.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Yup you need different methods to get the mouse position depending on if you're working in 2D or 3D unitycodemonkey.com/video.php?v=0jTPKz3ga4w

  • @kurooda9070
    @kurooda90703 жыл бұрын

    Thank you Code Monkey for the Tutorial! ^^

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

    Thank you for the video. I really enjoy all of your videos. If possible could you also cover saving and loading the grid with gridobjects and their state.

  • @darkfateinc7333
    @darkfateinc73334 жыл бұрын

    Can you tell me, how i can create a movepoints like a Heroes 3? (With highlight to allowed tiles) Hint where to look, please) (sorry for english if i wrote wrong anywhere)

  • @Novixel
    @Novixel2 жыл бұрын

    For the new input system :P using UnityEngine; using UnityEngine.InputSystem; public class GridTester : MonoBehaviour { private NovGrid grid; private void Start() { grid = new NovGrid(4, 2, 10f); } private void Update() { if (Mouse.current.leftButton.isPressed) { grid.SetValue(GetMouseWorldPosition(), 42); } } public static Vector3 GetMouseWorldPosition() { Vector3 vec = GetMouseWorldPositionWithZ(Mouse.current.position.ReadValue(), Camera.main); vec.z = 0f; return vec; } public static Vector3 GetMouseWorldPositionWithZ(Vector3 screenPosition, Camera worldCamera) { Vector3 worldPosition = worldCamera.ScreenToWorldPoint(screenPosition); return worldPosition; } }

  • @petethechin

    @petethechin

    Жыл бұрын

    Thanks for that, are you a Monty Python fan?

  • @sinistergeek
    @sinistergeek3 жыл бұрын

    I would like to see more!! Videos on Building Area. It really Helped

  • @hojaverde5265
    @hojaverde52654 жыл бұрын

    Excellent video! thank you very much for sharing it!

  • @hunter_nx987
    @hunter_nx9874 жыл бұрын

    Thanks for the tutorial. It's hard to find grid tutorials with this quality and simplicity of code. I swapped the Y axis for the Z to be flat to the ground for use in 3D projects. I will use it in a network culling and heatmap based spawn system's. I did an experiment and changed the array to a three dimensional array and it works the same way (it looks like Unity Umbra Culling). I just had to adjust error handling and debug view.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Thanks! Glad you like the video!

  • @HossamEldinBayoumy

    @HossamEldinBayoumy

    4 жыл бұрын

    That's great, can you share the code of using this in a 3D environment. It doesn't show for me.

  • @FSAirsoftUK

    @FSAirsoftUK

    4 жыл бұрын

    how do I switch the y axis to x axis

  • @pbthemass9374

    @pbthemass9374

    3 жыл бұрын

    how did you create it. i cant understand.please tell me

  • @katifurkan

    @katifurkan

    3 жыл бұрын

    @@pbthemass9374 Vector3 worldPositionMouse = new Vector3(Input.mousePosition.x, Input.mousePosition.y, -main.transform.position.z); Vector3 worldPositionMouse = main.ScreenToWorldPoint(worldPositionMouse);

  • @lachnload8723
    @lachnload87233 жыл бұрын

    Hey! Do you cover any optimisations for making a larger grid (100x100)?

  • @SebastianSeth

    @SebastianSeth

    Жыл бұрын

    If you are using int and you don't need too big values, make it short, or even char

  • @imc0der
    @imc0der2 жыл бұрын

    Simply and awesome explanation.

  • @joaniepepin4968
    @joaniepepin49684 жыл бұрын

    For the GetXY method, you should consider using the C#7.0 Tuple pattern. Microsoft consider it cleaner for multiple returns. I personally do not like multiple returns but sometimes they are unavoidable.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Yeah Tuples seem to be very interesting and would definitely be perfect in that scenario, I just haven't gotten used to using them yet. Unity is usually a couple of versions behind so I don't normally focus too much on the latest features added, although right now I believe Unity does support C# 7

  • @joaniepepin4968

    @joaniepepin4968

    4 жыл бұрын

    @@CodeMonkeyUnity Yeah, we're at 7 now. I think they change the official version a lot better now that Mono is no longer supported.

  • @saif0316
    @saif03163 жыл бұрын

    Bruh I'm trying to follow along at half speed and made it almost 5 minutes in so far :')

  • @33v4.

    @33v4.

    2 жыл бұрын

    same

  • @mk1rie909
    @mk1rie9093 жыл бұрын

    Thank you for the tutorial. Is there any way to rotate the grid in a 3d space?

  • @jlgaming9997

    @jlgaming9997

    2 жыл бұрын

    in the vector3 get world pos change it to: private Vector3 GetWorldPosition(int x,int z, int y) { return new Vector3(x, z, y) * cellSize; } and change the GetWorldPosition in the utilsclass line to (x, 0, y) thr u go hope it helps

  • @ilyasbenyahia2694
    @ilyasbenyahia26944 жыл бұрын

    Thanks a lot .. this is very helpful.

  • @lunarwilt329
    @lunarwilt3293 жыл бұрын

    Heya, awesome tutorial! Was wondering what your thoughts are on the built-in 2d tilemap and grid in Unity, and whether that can replace most of the manual work done here?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    It can but a Tilemap is just one of the possible use cases for this Grid Map. You can use this for logic and use the Unity Tilemap for visuals.

  • @Landon_Hughes
    @Landon_Hughes3 жыл бұрын

    Recommendation to those following along: Follow EXACTLY like how he has it! THEN, once you are done with all his grid tutorials, break things apart, play with them, and add your own spin just so you have a better feeling of the logic going on.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Yup that's definitely a great way to learn, first follow the tutorial exactly then start moving things around and see what changes.

  • @foamtoaster9742
    @foamtoaster97423 жыл бұрын

    For some reason the text that is displayed is very blurry. I tried changing the pixels per unit on the 1x1 sprite in your package but that didnt seem to do much at all. Also how would you go about using this system for large maps like in Factorio or if you wanted to procedurally generate an infinite map ? Thanks

  • @GlyphicEnigma

    @GlyphicEnigma

    Жыл бұрын

    Super late, but use textmeshpro.

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

    Thank you very much! Even tho this video is three years old it still works perfectly!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    I'm glad you liked the video! Thanks!

  • @ggeenncc1
    @ggeenncc14 жыл бұрын

    Thanks for the tutorial. Is it possible to use this heatmap for location information of HMD in VR? I have used Vive Pro, and i need user position data as heatmap for academic research.

  • @0_Vio
    @0_Vio4 жыл бұрын

    Useful Content as-well, Thanks

  • @gabethebabe3840
    @gabethebabe38404 жыл бұрын

    Hi code monkey I'm really new to this. To make this work for 3D terrains, you mentioned in the comments to swap XY vectors to YZ, but how how exactly do you do that? Is that done in the script or in the editor?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    In the code everywhere you see a Vector3 you replace the Y for the Z value. In doing so your Grid will be placed down in a 3D world ignoring height.

  • @gabethebabe3840

    @gabethebabe3840

    4 жыл бұрын

    @@CodeMonkeyUnity THANK YOU Code Monkey, thank u!

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

    Absolutely fantastic. Thanks a lot.

  • @SaltyDylpickle
    @SaltyDylpickle2 жыл бұрын

    This is really great, thank you! I wonder how much of this can be done using Unity's in-build Grid system? Like, is it possible to build off their existing system, rather than start from scratch?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    From what I know Unity's grid system is only meant for positioning things, don't think you can place logic in each grid position which is the main goal of my grid system kzread.info/dash/bejne/ap6mo7mteZu4iMo.html Same thing for the Tilemap, if you just want a grid with visuals then the default Unity Tilemap will work great, but if you want to add logic to each grid position then you need a different approach.

  • @wonkmy636
    @wonkmy6363 жыл бұрын

    Hi,Where the "MeshUtils.cs" is?

  • @Ziboo30
    @Ziboo304 жыл бұрын

    Need more ECS :D

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Yeah I definitely want to but at the same time there will be quite a few changes in 2019.3 so probably going to wait until then in order to not have outdated tutorials.

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

    Hello, some questions of detail: - why specify private, while it is the default access modifier? - grid.cs: in the constructor: in the double loop, why do you prefer gridArray.GetLength (0/1) to width / height? - grid.cs: in the SetValue method, why prefer debugTextArray [x, y] .text = gridArray [_x, _y] .ToString () to debugTextArray [x, y] .text = value.ToString (); ? I am a fan of your utilities ^^.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    - I prefer to keep my code as clear and consistent as possible, hiding the private would make me waste precious milliseconds thinking "if theres no access modifier then it must be private" - No specific reason, both contain the same value so use whatever you'd like - Again no specific reason, both have the same value, if you were doing that in production code you should indeed do value.ToString(); to improve performance but that's a debug line so performance is not an issue.

  • @TonySantolaria

    @TonySantolaria

    2 жыл бұрын

    - explicitly specifying the accesor is industry code standard. It facilitates readability as you don't have to think which is the default accesor - Code monkey is an experienced developer and it shows. Since you are using the gridArray inside the loop it is safer to use the GetLength in the constructors. Although not really meaningful in this simple scenario, it could be that width/heaight have been modified along the way. This kind of details make the code less prone to bugs with future changes - Same as above but a slightly better way would be to specify all in the same line debugTextArray [x, y] .text = gridArray [_x, _y] .ToString () = value; Also SetValue is more of a java thing. In c# you usually use properties or, in this case, you could use an indexer

  • @collinfarrell9718
    @collinfarrell97183 жыл бұрын

    Great video, thanks! I'd love to download your utilities but the reCaptcha just keeps failing to validate when I try to sign up.

  • @saumyasharma9993
    @saumyasharma99933 жыл бұрын

    I cannot download the project files and utilities as I am unable to receive the verification email from your website. When I click on resend email it says error so I cannot access the files. Please share the download link

  • @samvieten7224

    @samvieten7224

    3 жыл бұрын

    same issue @Code Monkey

  • @saumyasharma9993

    @saumyasharma9993

    3 жыл бұрын

    @@samvieten7224 I found it in my spam folder after some time. But not immediately

  • @vizualwanderer
    @vizualwanderer3 жыл бұрын

    Question: why can't you just use the built in grid system Unity has, is it possible to even implement it that way rather creating a whole other grid system via script?

  • @Yannychen

    @Yannychen

    3 жыл бұрын

    yes this is what I was thinking too it would help alot of he could make a video on it.

  • @Redbamboo-fb1gq
    @Redbamboo-fb1gq7 ай бұрын

    One thing I love about computer science is you don't even have to program in the same language to know what to do from any tutorial.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    7 ай бұрын

    Yup! I've learned lots of stuff, especially programming patterns, by watching Java/C++ tutorials

  • @user-em9su3dd9y
    @user-em9su3dd9y3 жыл бұрын

    Awesome, thank you!

  • @johncotrone2767
    @johncotrone27673 жыл бұрын

    Using his numbers, my grid is huge. I know I can increase the camera size or I can decrease the cell size in the code, but how does it know what a cell size of 1 is equivalent to in the game in the first place? I changed the cell size to 1 in his code but the size if the resulting cells in the sceme don't seem to correspond to anything in the scene or in the settings that I can tell.

  • @adritopoangel

    @adritopoangel

    3 жыл бұрын

    I guess that you already solved the problem, but in case someone else has the same issue the solution is very simple, go to the Main Camera object and increase the Size value

  • @johncotrone2767

    @johncotrone2767

    3 жыл бұрын

    @@adritopoangel no not yet. My code was working but my question was, what does a cell size of "one" mean? What is it equivalent to. I know to change it, but I don't know why it ends up being the size that it ends up being when I change it to one.

  • @potatoes131

    @potatoes131

    3 жыл бұрын

    @@johncotrone2767 1 here translates to 1 unit. They don't really translate to anything meaningful like a foot or meter but if you make an object at position (0, 0, 0) and another at position (1, 0, 0) they'll be one unit apart. Orthographic cameras in unity seem to use the size field as the distance from the center to the vertical edges kinda like a radius. A camera with a size of 5 will be 10 units tall and an appropriate amount wide dependant on your aspect ratio. E.g. A camera with a size of 5 and an aspect ratio of 16:9 will be 10 units tall and 17.777... units wide. With a cell size of 1 you would be able to fit about a 10x17 grid on screen. Either increase camera size or decrease cell size to get more cells on screen.

  • @bigboobmasterbaiter69

    @bigboobmasterbaiter69

    3 жыл бұрын

    seems like your units are set to something else. a unit is like one meter but in unity.

  • @arthurraposo2110
    @arthurraposo21104 жыл бұрын

    I can´t do the "MeshUtils" work, help pleaaaseeeeeeeeeeeeee.

  • @ugur5721

    @ugur5721

    3 жыл бұрын

    same for me

  • @fedorrussel3810
    @fedorrussel38103 жыл бұрын

    Dude you're awesome!

  • @mindbdsm9036
    @mindbdsm90364 жыл бұрын

    Awesome tutorial, really hard to find something so useful. What about expanding the grid? For example if it where plots that you need to expand, would just adding new grid next to existing be a good approach? Or should somehow existing grid be update to new size?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    For expanding the grid you would need to create the new size array and copy everything from the old array. But that can be a costly operation so if its something that happens often then having the grid bigger by default and simply having some grid cells disabled might be a better approach. Check out the video after this one where I implement generics which allows you to make the Grid based on a custom object that you can then add inside a simple valid boolean.

  • @mindbdsm9036

    @mindbdsm9036

    4 жыл бұрын

    Thanks. Yep I checked the video and this is the way I started to go, having bigger grid and disabling certain cells. Later on might switch to having multiple grids since there will be fixed size for each and fixed amount of plots, only downside to this that I actually see is iterating through them in that case. Keep up with the videos, they are really informative. :)

  • @marscaleb
    @marscaleb8 ай бұрын

    Is there a way to set up a grid to appear and be edited within the editor? So I can set up a grid to use for various gameplay reasons, but not have it shown to the player.

  • @kevinguiboche2359
    @kevinguiboche23592 жыл бұрын

    i'm moving on because its not that big of a deal but i was having an issue with my grids not spawning how your grids were, the two smaller ones spawned how yours did but the bigger one overlapped, so im hoping this doesnt have bigger repercussions in the future, but maybe someone else had this issue or hopefully you might know why that would happen. thanks a lot and i love your videos by the way

  • @zeroomega3781
    @zeroomega37814 жыл бұрын

    Hope this will become a series that teaches people how to make Fire Emblem games

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Sure that would definitely be one possible use case for a Grid Map.

  • @tonyclx
    @tonyclx3 жыл бұрын

    @Code Monkey I have a null reference exception error when I reference code: grid.SetValue(UtilsClass.GetMouseWorldPosition(), 56); in Testing.cs Can you please help me? I a beginner and has very little knowledge of C#. Thank you for your great tutorial videos and utilities

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    You have something set to null kzread.info/dash/bejne/Z52m2JVpXcW6eto.html

  • @chocobo678
    @chocobo6784 жыл бұрын

    Hi, again great video! How could one change (or add in this case) different sprites for the grid cells? Is just making a background image with the entire scenario a good option?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    I've used this system as a base to create a Tilemap which lets you set a sprite per grid position kzread.info/dash/bejne/mXhpp7OypJq8gM4.html

  • @chocobo678

    @chocobo678

    4 жыл бұрын

    @@CodeMonkeyUnity thank you sir! by the way, is there a linear playlist that I can follow the entire tutorial? I started with the A* but had to came here for the grid system first. See ya!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    @@chocobo678 Here's the Grid System playlist kzread.info/head/PLzDRvYVwl53uhO8yhqxcyjDImRjO9W722

  • @user-bu9ys4it2f
    @user-bu9ys4it2f9 ай бұрын

    Can you explain the pure logic behind grid map for if someone wants to make this in playmaker or Bolt? & are you using list, array, hashtable or dictionary to store the gridcells and underlying grid data?

  • @HeavenlyWhispers245
    @HeavenlyWhispers2452 жыл бұрын

    Thank you very much

  • @petervishneski7947
    @petervishneski79472 жыл бұрын

    This is really wonderful. If, instead of using the mouse, I want to create a cursor that starts on a certain grid space that is controlled with arrow keys, do you know the unity language for that? I'm assuming I'll need to set up the cursor in a world position, then Input.GetKeyDown whatever key I assign. How do I set up this cursor?

  • @kevinguiboche2359

    @kevinguiboche2359

    2 жыл бұрын

    did you ever figure it out?

  • @lAztechl
    @lAztechl3 жыл бұрын

    Thanks for the Great Tutorial. Just asking. Is this class can hold an Item with a varied size? like for example, a building can take up to 2x2 of the grid? can you give a recommendation on how can I approach this?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    You can have a building class and place the same reference on multiple grid positions. When placing the building you could consider the mouse position to be the lower left corner of the building, so if the mouse is over 1, 3 then you place the building on 1,3; 2,3; 1,4; 2,4

  • @lAztechl

    @lAztechl

    3 жыл бұрын

    @@CodeMonkeyUnity Thank you for a great response. It really helps.

  • @mveden82
    @mveden822 жыл бұрын

    First of, love your work and contribution to the community. Just one pointer which maybe you heard before. The parts where you are doing the C# parts are done incredibly fast. Which I understand, as for you it's something your probably done 1000 tines before 😂 but these part are the more important and interesting parts for me as a new comer. A little more focus on that would make your videos better then they already are 😊

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    The main issue is the KZread algorithm, If I don't speed up the code then people drop off during those parts, or the video ends up too long and no one clicks on it. That's one of the benefits of courses, in my courses I'm not beholden to any algorithm so I can take as much time as I need

  • @Ceyx100
    @Ceyx1003 жыл бұрын

    hey congrats for the vids first of all, then I wonder whether I should use the unity tilemap system which is very handy to paint and stuff or your grid system ? or a combination of both ? it's for making an RTS game btw. Thanks !!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    You can combine both, Unitys Tilemap for visuals and this Grid for logic. Or use the Tilemap that I built on top of this grid and use the same underlying logic kzread.info/dash/bejne/mXhpp7OypJq8gM4.html All approaches are valid

  • @VandoSalgueiro
    @VandoSalgueiro2 ай бұрын

    Obrigado pela tua partilha de conhecimento Code Monkey. Tenho aprendido imenso contigo. x]

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 ай бұрын

    Nice! Boa sorte com os teus jogos!

  • @TinyDeskEngineer
    @TinyDeskEngineer2 жыл бұрын

    Was this video made before the Grid component was added to Unity? Because I had to replace the Grid name with GridMap and it caused a little confusion when I made the Testing script and used Grid instead of GridMap.

  • @nicospadoni5328
    @nicospadoni53283 жыл бұрын

    Hey man, this tutorial is fantastic! I'm having a little bit of trouble making the mouse input return the right value when i tilt the camera angle though. Any ideas?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    If you're using a 3D camera then you need to use a different method for getting the mouse position, you need to fire a Ray from the camera and add some sort of floor collider.

  • @nicospadoni5328

    @nicospadoni5328

    3 жыл бұрын

    @@CodeMonkeyUnity Wow, what a fast reply! Thanks! I'll try that out, then. I wonder if I can mix it up with tilemaps? I'll watch your tilemap video and see what I can come up with. Thanks!

  • @cgh353
    @cgh3534 жыл бұрын

    Thanks I went through the tutorial step by step. if i wanted to get mouse position with camera in perspective view instead of orthographic do i still use ScreenToWorldPoint or something else? because it wasnt working in perspective.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    With perspective you would use camera.ScreenPointToRay(Input.mousePosition);

  • @cgh353

    @cgh353

    4 жыл бұрын

    @@CodeMonkeyUnity Oh Ok ,Thank You!

  • @rutchjohnson

    @rutchjohnson

    4 жыл бұрын

    To build off this more: for 3d scenes I got this to work. Switch all y to z. (you will need to expand Vector3 statements to new Vector3(x, 0, z)) Then to use this code to do the screenPointToRay: private Grid grid; private Ray ray; private RaycastHit hit; private void Start() { grid = new Grid(2, 4, 10f); } if (Input.GetMouseButtonDown(0)) { ray = Camera.main.ScreenPointToRay(Input.mousePosition); if(Physics.Raycast(ray, out hit)) { grid.SetValue(hit.point, 56); } } ALSO Your plane object will need to have a collider on it for the raycast to register.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    @@rutchjohnson Yup, I used a 3D XZ version of this class in the Wash Your Hands game

  • @Bmacorr

    @Bmacorr

    3 жыл бұрын

    @@rutchjohnson wow thank you. I was struggling with this for so long!

  • @fkkirk3714
    @fkkirk37148 ай бұрын

    Hi, thanks so much for this tutorial... I have tried to follow through but am getting stuck at 16:40... when I click outside, the first cell at 0,0 is changing to 56, regardless if I am outside or inside the grid and no other cells change when I click them... inside the gird. Code is identical to yours up to this point... but I am wondering about the camera setup... you have a GameHandler object in the Hierarchy from the start, there is a Game Handler_Setup (Script) on it, but no where does this tutorial show when you added this, how to add it, what it is? Is there another tutorial on this please, you could link to. thanks so much Kirk

  • @fkkirk3714

    @fkkirk3714

    8 ай бұрын

    ok... I have solved the issue I was having, the camera needed to be set to Orthagraphic Mode - my bad, must have missed that in the tutorial - everything working now.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    8 ай бұрын

    Yup how you get the mouse position is different in 2D and 3D unitycodemonkey.com/video.php?v=0jTPKz3ga4w

  • @RRaiho
    @RRaiho2 жыл бұрын

    Amazing work thank you, though one question... if i want to have spaces between cells (GridObjects) how would i do that with your system?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    The positions in the cells are all based on math, so just add some gap in the calculations converting grid position into world positions.

  • @jeson2034
    @jeson20342 жыл бұрын

    Man i wish every unity tutorial was just like you fast straight to the point doesn't waste time rewriting every code , just one question I'm trying to make this for an isometric game so the cells need to look more like a parallelogram and be rotated a little bit do you have any idea how to approach it with your code

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    The best approach is to keep the underlying logic on a normal rectangular grid and only place the visuals on a isometric view. Or you can just do some math and convert the grid to isometric, all that matters is the conversion from world space to grid space.

  • @jeson2034

    @jeson2034

    2 жыл бұрын

    @@CodeMonkeyUnity thanks

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

    Love the video! Been wanting to work with a grid based system for a long time, finally have the time to give it a try! Quick question, I got to nearly the end of the tutorial where you click on a grid cell to change the value, but every time I click it sets the same grid square to the value. It never sets the actual grid I am clicking on, and it even changes that same grid value if I click outside the grid pattern. Have you ever seen this odd bug? [ANSWER] I found it! I need to change the "Projection" setting on the camera object itself from perspective to ortho. That was a tricky one because I tried changing the projection setting from the "#Scene" window, but I needed to change it in the gameobject. Tried going just a little bit further to see if I can identify the bug. If i use the right click to get the value, after I change the value of one tile (Which is always changing the same tile) no matter which tile I right click on after that it returns the value of that single changed tile. This is very odd. I've gone over the code you have a dozen times and can't find a single place where my code is different from yours. [Update] OK I think I found somewhat where the code is failing, but I'm not sure why it is failing. The tile that is directly in front of the camera is the tile that is being affected. So for some reason the code that is trying to find where I clicked is only finding the tile that is straight forward from the camera. Not entirely sure why its not grabbing the position of where I click. If I run: if (Input.GetMouseButtonDown(0)) { Debug.Log(UtilsClass.GetMouseWorldPosition()); } then it just returns the position of the camera, but with 0 z axis. The only thing I can think would be wrong is he UtilsClass is somehow grabbing the wrong info. After doing a ton of debugging, it all seems to be debuging properly except for grabbing the correct spot on the screen (I can debug for mouse position and it works fine)

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Yeah the method for getting the mouse position is different in 2D or 3D, I covered both methods here unitycodemonkey.com/video.php?v=0jTPKz3ga4w

  • @Landon_Hughes
    @Landon_Hughes3 жыл бұрын

    16:30 During this part, I get a NullReferenceException: Object not set to instance of an object using your package 🤔 This resorted to me making my own way of getting the current mouse position. Other than that, great series! I will continue to watch ✊ Edit: Figured it out, I didn't tag my camera "MainCamera" 😅

  • @PorroYMonster

    @PorroYMonster

    2 жыл бұрын

    Thanks!!!

  • @oyuncubirlii
    @oyuncubirlii4 жыл бұрын

    amazing just amazing

  • @nbixel
    @nbixel7 ай бұрын

    If you want the grid "top down" like in a 3d game you can rotate the TextMesh by adding this line in the main constructor >> transform.rotation = Quaternion.Euler(90, 0, 0); and for the GetWorldPosition, put the y value in the z slot like this >> return new Vector3(x, 0, y) * cellSize;

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    7 ай бұрын

    Yup, that's pretty much what I did when I converted this to 3D for the Building system unitycodemonkey.com/video.php?v=dulosHPl82A

  • @pauloarturmorgantijunior2257

    @pauloarturmorgantijunior2257

    6 ай бұрын

    Thanks for the tip. Maybe when running the code, the mesh doesnt allign with the gizmos. In this case, its just to insert 0 in the y position when evaluate the cellSize >> CreateWorldText(gridArray[x,y].ToString(), GetPositionWorldPosition(x, y) + new Vector3(cellSize, 0, cellSize) * 0.5f);

  • @a.nanasov
    @a.nanasov Жыл бұрын

    Great video, thank you! I have a question: new Unity versions have native Grid component, are there any benefits of using custom grid implementation over using the implementation provided by Unity? Do you have plans to make a video about the native implementation?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    The built-in Grid is meant for positioning objects, whereas this Grid System is primarily meant for logic. On this first video it's hard to see the difference but in future videos expanding upon this grid it becomes more clear unitycodemonkey.com/video.php?v=8jrAWtI8RXg unitycodemonkey.com/search.php?q=grid

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

    This video was incredible, a bit quick for me, but incredible. I've been having issues with creating a sliding puzzle type game where the unity physics is betraying me. Could I use this to instead track where my block/s is/are and available/unavailable locations to move it?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Sure, if your objects only slide horizontal/vertical then it's pretty easy. I've expanded upon this system in many other videos unitycodemonkey.com/search.php?q=grid For your use case perhaps the closest would be the Grid Building System to learn how to place objects on the grid unitycodemonkey.com/video.php?v=dulosHPl82A Or perhaps the Tetris Inventory unitycodemonkey.com/video.php?v=fxaDBE71UHA

  • @Nuan07

    @Nuan07

    Жыл бұрын

    @@CodeMonkeyUnity I will be watching all of them! I don't understand how my "fun little passion project" turned into such a nightmare haha. Thank you for the videos and thank you for the response.

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

    Thank very much for this tutorial! I am very new to Unity, and I was hoping to put random values on each grid. Any idea how to randomize the values of each grid every time I run the program? That would be lovely.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    You cycle through the grid on the X and Y from 0 until width/height and on every grid position get the underlying GridObject and call a function to set a random value. Run that logic right after creating the grid.

  • @herolegaspi6421

    @herolegaspi6421

    Жыл бұрын

    @@CodeMonkeyUnity I really do hope that I can understand what you just said. My deepest apologies. I will keep on figuring out how this code runs line by line, and then apply the instruction you gave me. Thank you!

  • @davidpak271
    @davidpak2713 жыл бұрын

    I've seen this a couple of times in your videos now. What is the difference between having/not having Monobehavior in a script? Thanks.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    If you have it you can attach it to a game object as a component and you have access to the standard functions like Start() and Update() If you don't add it then you have a standard C# class. If you don't need to add as a component or you don't need the functions then there's no need to make it a MonoBehaviour

  • @yudnai5577
    @yudnai55772 жыл бұрын

    i like this tutorial i think snap prefabs to the grid will be cool :)

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    That's pretty much what I did in my Grid Building System kzread.info/dash/bejne/lqmg0dWBgM-eYqQ.html

  • @yudnai5577

    @yudnai5577

    2 жыл бұрын

    @@CodeMonkeyUnity oh ok I'll check it out thanks.

  • @pamhs368
    @pamhs3684 жыл бұрын

    Thank you so much!!!!!!!!!!!

  • @jordanpickfordisgreat1533
    @jordanpickfordisgreat15332 жыл бұрын

    Thanks, great video only two questions. How do I make it 3d for the grid building system video and also for the grid building video do I have to complete both this video and the powerful generics video. Thank you

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Check out the full playlist. This "series" wasn't planned ahead of time so the videos are more to teach you how the underlying logic works and not meant as a step by step course.

  • @jordanpickfordisgreat1533

    @jordanpickfordisgreat1533

    2 жыл бұрын

    @@CodeMonkeyUnity thank you very much

  • @nashordrake3378
    @nashordrake33784 ай бұрын

    Question, my version of a grid map is creating a cell class containing a vector2 and storing them in a dictionary. So if i set my width and height to 200x200, a nested for loop would start, creating a class for each x and y and storing them in a dictionary with their keys being their coordinate. Is that method efficient? It makes accessing them easier but im not sure if its memory efficient or amthing

  • @nashordrake3378

    @nashordrake3378

    4 ай бұрын

    Also i made the cells classes so i can let them hold more information, like are they water cells or land cells etc

  • @sebastianp2472
    @sebastianp24722 жыл бұрын

    Thank you very much for this insightful tutorial - I wonder, if a hexagonal grid is also creatable in that way? There is this tilemap editor in Unity as well - does it do the same like the grid you created here? or are they compatible in some way? I appologize, if the answers are obvious to some people, all of this stuff is very new to me and I try to figure these things out and how the things interact with each other.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    The "shape" of the grid is just based on math, so if you use hex math when converting world positions into grid positions then it will be a hex grid. I'm not very good at math but I'm sure there's an equation for that. The Tilemap editor is a completely separate system, the main difference being that I use this grid mainly for logic whereas the built-in Tilemap is more used for visuals.

  • @pepsipwns666
    @pepsipwns6662 жыл бұрын

    I had this working with pathfinding for weeks now, I've come back after doing work elsewhere on my game and now the GetMouseWorldPosition is returning values slightly off 0,0... I'm not sure what has changed or why? Its like, 11,4 everytime even though im clicking at 0,0. It seems to now be taking the bottom left corner of camera as 0,0 and not where my grid was (at 0,0 worldspace) Edit: It seems to break with the pixel perfect camera attached to my main camera... but I swear it was working with this before... I re-added the pixel perfect cam and it fixed it...

  • @iknowcturne7362
    @iknowcturne73622 жыл бұрын

    Hello ! I know this video is quite old now, but how did you manage to make your street pavement in your battle royal tyccon, to match depending if it's a corner or a straight "road" ? Like how would you build a road and make it adapt if it's an intersection, a corner, a turn or other ? Thanks you

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    You check the neighbour grid positions then select the correct pre-drawn sprite. Is there a Road object above and below? Then select the straight vertical road. Is there a Road left but not right? Then select the road end left visual. Etc Basically just a ton of ifs for all combinations to select the correct sprite

  • @iknowcturne7362

    @iknowcturne7362

    2 жыл бұрын

    @@CodeMonkeyUnity Thanks you, very clear help, i managed to make it work for a 3d grid building system, with room walls adapting to nearby walls, bunch of raycast and if statement like you said ! Thanks 😁

  • @jorgemachado6403
    @jorgemachado64033 жыл бұрын

    hello i'm new to your channel, it would be nice to teach you how to move the character on the grid i think it would help some people who are starting, like me for example, but thanks for the video it helped a lot

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    I made a Grid Combat System here kzread.info/dash/bejne/n4OCqtecn7yng7g.html

  • @chanceslaughter3237
    @chanceslaughter32374 жыл бұрын

    Is there a way to use text mesh pro for better quality instead of using a simple unity text element? I had to make the text and size much smaller to fit my games size, but upon scaling the text down in the UtilsClass, it got very pixelated in-game. Edit: or a way to make normal text elements higher resolution when scaled down?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Use a higher fontSize, like 30 combined with a small characterSize like .3f, that will render it at higher resolution and scaled down

  • @vadimkorobkin1565
    @vadimkorobkin15654 жыл бұрын

    Awesome guide;