Powerful Generics Added! Grid System in Unity (Terraria, Minesweeper, Tilemap)

✅ Get the Project files and Utilities at unitycodemonkey.com/video.php...
Let's add C# Generics to our Grid System. This allows us to use the Grid with any object type we can think of to solve whatever problem we have.
Grid System in Unity (Heatmap, Pathfinding, Building Area)
• Grid System in Unity (...
Make Awesome Effects with Meshes in Unity | How to make a Mesh
• How to make a Mesh in ...
Quadrant System in Unity ECS (Find Target/Obstacle Avoidance/Boids)
• Quadrant System in Uni...
Battle Royale Tycoon on Steam
store.steampowered.com/app/85...
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

Пікірлер: 268

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

    Play 7 Awesome Games and help support the channel! (Action, Strategy, Management) Get the Game Bundle at unitycodemonkey.com/gameBundle.php See what I'm teaching here applied to real games!

  • @lyricsmaker-poplyricsmaker1183

    @lyricsmaker-poplyricsmaker1183

    3 жыл бұрын

    how can I get your code from your package so I can change it a little bit?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    @@lyricsmaker-poplyricsmaker1183 There's a link in the description

  • @rambovalle8881

    @rambovalle8881

    3 жыл бұрын

    Help. public Vector3 GetWorldPositionFromValue(T value) { Vector3 pos = new Vector3(0, 0, 0); for (int x = 0; x { for (int y = 0; y { if (gridArray[x, y] == value) { pos = GetWorldPosition(x, y); } } } pos.x += 5.5f; pos.y += 5.5f; return pos; } error CS0019: Operator '==' cannot be applied to operands of type 'T' and 'T'

  • @mrmogelost6720

    @mrmogelost6720

    3 жыл бұрын

    ​@@rambovalle8881 Change your if statement that checks the value parameter to this: if (gridArray[x, y].GetType() == typeof(value)) I think it just might work, I'm a bit of an intermediate myself.

  • @rambovalle8881

    @rambovalle8881

    3 жыл бұрын

    @@mrmogelost6720 Nope (ToString() works but that doesnt work with evrything because if its custom class it will just comparre names if i remember correctly but i will use it unitil something better comes out)

  • @pawepawowski9506
    @pawepawowski95064 жыл бұрын

    Please reorder your Grid System in Unity playlist this should be 3rd, not 2nd part because you use and modify code from the heatmap video and it is super confusing. I almost rewatched full grid video to search what I missed but then I noticed that the heatmap video upload date is between this and first one so after heatmap video it makes so much more sense.

  • @Hello-qg4yk

    @Hello-qg4yk

    3 жыл бұрын

    Yes thanks

  • @seanloughran6714
    @seanloughran67142 жыл бұрын

    Being able to pass functions as a parameter is so handy. As always, super amazing video filled with so much knowledge!

  • @Definitely_a_Fox
    @Definitely_a_Fox4 жыл бұрын

    Ah! Having a Tilemap system would be very nice! Unity's Tilemap system doesn't exactly do what I want it to do, but making my own may help me out! Just going to wait for the next video!

  • @Toopa88
    @Toopa884 жыл бұрын

    Just thought about world generation earlier that day, nice 👌

  • @yaroslavmakarov2218
    @yaroslavmakarov22184 жыл бұрын

    Amazing content! Thank you very much!

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

    Being able to use any type is fantastic

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

    Excellent contents! Thank you!

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

    Excellent presentation of Lambda use, when you havent done it in a while its a great refresher

  • @gordorodo
    @gordorodo4 жыл бұрын

    Great tutorial! Thanks man! I would change just one thing on your implementation. Your HeatMapGridObject shouldn't hold a reference to the grid since you are creating an unneeded cross-reference plus the need of adding all those parameters to the constructor. What I would do is have the HeatMapGridObject raise an event whenever it is modified, and whoever knows that GridObject can subscribe to that event, in our case, your Grid. So, the Grid, when creating all its objects, it also registers to the event and handles it in whatever way it desires. It's a very simple change but I believe it enforces better encapsulation and simplifies the construction.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Yup that is indeed another approach and actually what I use in the Grid System that I've used in my games for several years now. I tried to keep the video simple so I figured having the object contact the grid would be easier to follow than events.

  • @gordorodo

    @gordorodo

    4 жыл бұрын

    @@CodeMonkeyUnity yeah good point, adding that doesn't necessarily add to the grid system tutorial and might make things confusing for beginners. Anyways, great job bro, love your vids!

  • @BetrayedGecko

    @BetrayedGecko

    4 жыл бұрын

    @@gordorodo Can you go into a bit more detail about how you'd do this with generics? So do you create a delegate in your HeatMapObject? If so how do you get the grid to subscribe to that event without creating a dependency on the HeatMapObject?

  • @skelhain

    @skelhain

    4 жыл бұрын

    This is not possible if you want the grid to be generic. It would need to know about specific types to subscribe to their OnChanged event. Other than creating a big type casting mess, which creates lots of dependencies, there is no other way than what is shown in the video, but I'd be happy to be proven wrong!

  • @tomfebry

    @tomfebry

    3 жыл бұрын

    @@skelhain ​​You can just use an interface like IGridObject and have the event in there, couldn't you? public class Grid where TGridObject: IGridObject public interface IGridObject { public event Action OnValueChanged; } gridObject.OnValueChanged += () => { OnGridValueChanged?.Invoke(this, new OnGridValueChangedEventArgs {x = x1, y = y1}); }; _gridArray[x, y] = (TGridObject) gridObject;

  • @Xerisis
    @Xerisis2 жыл бұрын

    So the issue with the HeatMapVisual file getting errors is that the Grid class has the same name as a built-in Unity class. So as soon as it was changed to generics, the HeatMapVisual script started referencing the Unity class instead of the Grid class we created. Comment that script out until you hit the part in the vid where it gets fixed.

  • @KetoneCharger
    @KetoneCharger2 жыл бұрын

    thanks for this. i've bought your course too!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    I hope you like it! Thanks!

  • @Erfo7783
    @Erfo77833 жыл бұрын

    Hello, thanks for yet another great video, awesome pace, awesome concepts. I have a question, at minute 16 you implement a bunch of code to trigger the grid update, creating also a cross dependency between the grid and the object. Isn't it easier if you just call the set function from the testing script? // I use a dictionary for the grid cells) if (Input.GetMouseButtonDown(0) && index >= 0) { HeatMapObject heatMapObject = myGrid.GetGridObject(index); if (heatMapObject != null) { heatMapObject.AddValue(cellValueStep); myGrid.SetGridObject(index, heatMapObject); } }

  • @Eck314
    @Eck3144 жыл бұрын

    @Code Monkey - It seems like the Heat Map video should be in a different order. Can you drag the Heat Map video up to be the 2nd video in the Play List?

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

    Excellent video that showed me all the interest of generics, topic that I had left aside until then. New subscriber to your channel, I like the rhythm of your videos and your posted flow, which allows me to follow without making constantly pause or reverse. I think it's possible to use hexagonal grids, maybe even Unity provides something on these grids. Can you give me a track? Thank you.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Thanks! Glad you like the videos! Hmm hexagonal grids are a very interesting concept, it seems like it would function exactly the same except for Odd row numbers you would shift the position to the side by half the cellSize. Could make for a very interesting video, I'll look into it, thanks! I believe Unity's Tilemap system already supports Hexagonal maps, so if you don't need special complex logic inside your tiles then that should do just fine.

  • @hypedoncoffee2884

    @hypedoncoffee2884

    11 ай бұрын

    @@CodeMonkeyUnity Are you able to override the Unity Grid to add additional logic similar to your implementation? Did Unity add their grid after this video, and that's why you made your own implementation?

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

    Your grid system is super cool, here is one idea of potential future tutorial if you ever get interested in it. Combination of Wave function collapse and grid system to generate levels.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Yup that's one topic I've had on my to-do list for a long time, it's a really interesting way of generating levels, I've never used it myself so need to find the time to really research it.

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

    Hi, thanks for your precious tutorials! for some reason I cannot manage to print, on the grid of StringGridObject, letters and numbers on 2 lines... even putting in between... I tried to use Environment.NewLine but the result doesn't change... Any ideas?

  • @devnest4623
    @devnest46232 жыл бұрын

    i like the informative and unique information you deliver not many does work stuff like this but i d argue again the quality of the editing. if you aren't well advanced you will totally get lost. so many important details get so lost by the editing i assume

  • @user-dg5uo9ht4v
    @user-dg5uo9ht4v4 жыл бұрын

    Love it! can you make a video about produceral animation tutorial? i'm really waiting for that!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    That is a very interesting topic that I'd definitely love to explore at some point

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

    One small error I think. You should assign mathf.clamp to value so that when adding value it will never exceed 100. But it's not that relevant to the topic of this video. Excellent tutorial! Really appreciate it!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Yeah for a Heatmap adding a little validation to the values would be a good idea. I'm glad you found the video helpful!

  • @julianhoogendoorn8640
    @julianhoogendoorn86402 жыл бұрын

    Hey guy, I'm loving your tutorials. I'm just a bit confused about the playlist they're in. When I followed the first one about making the grid, this pops up as the next one. But you already did heatmap related stuff in here. And that is the 4th video in the playlist, which in turn seems to build on previously unbuilt stuff. Is it the correct order?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    This Grid class wasn't really planned ahead of time, I just started building and kept building on it, so there were some simple things I made outside of the videos and the videos weren't planned to go from one directly to the next. The order in the Playlist is based on learning the core first and then various implementations of it. You don't need to make the heat map or the tilemap to learn how it works, but watching those videos will give you more ideas for various use cases.

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

    Super video, very clear and which shows the interest of the generics. I'm just pointing out that the normalized value is incorrect, because it ignores the minimum value: (value - min) / (max - min). In the video, min is 0, so no visible error. I did not find the town map video indicated at the end of the video (20:12). Unless it is "Custom Tilemap in Unity with Saving and Loading (Level Editor)"?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Yup it's the Tilemap video kzread.info/dash/bejne/mXhpp7OypJq8gM4.html

  • @AbuSalmanAngoli
    @AbuSalmanAngoli4 жыл бұрын

    Hello there! I really apreciate your channel! One question: Why won't you use Unity's Tilemap fro your games?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    I prefer the flexibility of using my own and since its linked to my custom Grid System I can have the visual and the underlying logic sharing the same pattern. If you don't need any logic and just want visuals then Unitys tilemap is great

  • @Ryan-ww7un
    @Ryan-ww7un2 жыл бұрын

    I'm really interested in learning how to eliminate the coupling between the grid object and the grid. So far I understand I can use a generic type constraint on the grid class to limit the type to those that implement a given interface. I'm unsure about the structure of the interface, and what changes I'd need to make to the grid and object classes. Any help would be greatly appreciated!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    By using generics it's already decoupled, you can define a specific GridObject for whatever you want to build. I've built many systems on top of this and they all use different GridObject definitions kzread.info/dash/bejne/dZiX0Jiue5zNgNI.html kzread.info/dash/bejne/mKyVpqR-Z5S7eKQ.html

  • @coldwire3684
    @coldwire36844 жыл бұрын

    Implementing the IEnumerable interface on the Grid class would allow LINQ queries to run against it. Do you think that would be valuable?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Yup if you tend to use LINQ a lot that is definitely a good thing to add.

  • @lolocustlol
    @lolocustlol2 жыл бұрын

    Hey i love your tutorials, just my opinion but it would have been easier to follow for me if you had done the letter and numbers example first and then the heat map

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

    Hey CM! Great stuff as usual. Do you have any tips on how to persist such a grid? Like is it possible to have a scriptable object that can save a grid object with a generic type?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    For saving on a scriptable object you'd need a way to serialize your generic type. So basically what I covered in the Tilemap video with a Save Object for the generic type unitycodemonkey.com/video.php?v=gD5EQyt7VPk unitycodemonkey.com/video.php?v=6uMFEM-napE

  • @LautaroArino

    @LautaroArino

    Жыл бұрын

    @@CodeMonkeyUnity Amazing. You are just a chest of treasures.

  • @zodi4991
    @zodi499110 ай бұрын

    @CodeMonkeyUnity Hello, around 16:20, when I click on my grid it doesnt change the value. But I have written everything you did and I have no errors, what could be causing it to not work?

  • @duskhammer8
    @duskhammer89 ай бұрын

    I have been going through this video and the others before this on the playlist for a while now and am not able to get the event to update that grid. so my question, if you happen to see this is, how is OnGridObjectChanged(this, new OnGridObjectChangedEventArgs { x = x, y = y }) actually updating the grid visuals? i have checked everything else and have confirmed that the value is actually updating. and i have put Debug.Logs() throughout the event code to make sure i am hitting all the methods. but i am just not able to get the visuals to update. and am not sure why newing up an OnGridObjectChangedEventArgs is changing the visuals at all. if you would be able to answer that would be a big help, Thank you! and also Thank you for making these tutorials in the first place. they are great!!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    9 ай бұрын

    The event is being listened on the debug logic On the Grid constructor, line 58 at 4:48, it listens to the event and updates the debug object

  • @gadgetboyplaysmc
    @gadgetboyplaysmc4 жыл бұрын

    You never really showed how you created the EventHandler OnGridValueChanged. I mean you showed a little bit of it in the first video on Grid Systems. But man... The way your tutorials are so interconnected and sequentially inconsistent made this really complicated to follow. Another thing is how you use the your Utils class, which may be very useful, but it was pretty difficult to actually absorb the information when there's that little black box aspect in the tutorial. I mean I can't really complain since all of this is free, so believe me I'm truly grateful. It's just super frustrating to end up being stuck in the middle because I didn't know how that one method or variable is supposed to exist. In the end I kinda got it down together tho.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Events are pretty basic C#, I covered them here kzread.info/dash/bejne/gamO1Mqym7nfpMo.html kzread.info/dash/bejne/aYqg282Go9bAqs4.html This is a pretty complex class, if you're a beginner then it will take you more than just a few minutes to understand everything. It's your learning journey, take your time, it's not a race.

  • @lens3973

    @lens3973

    2 жыл бұрын

    @@CodeMonkeyUnity events are basic c#, so you don't show them? That's awful logic. Just admit the mistake, and put the fix in the description. How you are acting is immature and egotistical. How is everything else in this video not also basic c#? Isn't that the point of the tutorials, to help beginners learning c#? Or is it to provide incomplete tutorials so people have to sign up to your stupid website just to download the files. Oh, and also buy my coding course (is that where you actually teach basic c#?). You obviously only have your own interests at heart.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    @@lens3973 What?

  • @lens3973

    @lens3973

    2 жыл бұрын

    @@CodeMonkeyUnity what part didn't you understand? You purposefully limit your free content just to sell your courses. Why aren't your project files on GitHub like every other tutorial on YT? You don't care about the coding or sharing knowledge, just getting your $$$.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    ​@@lens3973 I don't even have any course related to this Grid System or C# itself. All of the videos in the Grid System series are completely free right here on KZread kzread.info/head/PLzDRvYVwl53uhO8yhqxcyjDImRjO9W722 All of the C# videos that I've made are also all here completely free on KZread kzread.info/head/PLzDRvYVwl53t2GGC4rV_AmH7vSvSqjVmz And the project files are completely free to download, none of the project files from my 450+ videos are behind a pay wall. So again I have no idea what on earth are you talking about, 90% of everything I make is completely free, are you confusing me with someone else?

  • @Bmacorr
    @Bmacorr3 жыл бұрын

    Hi CodeMonkey, thank you so much for creating these tutorials. I had a question about modifying this for a 3D project. I seem to have it working, but only the cubes along the the first X axis seem to have their values changed. I can tell that the other square values are getting their positions pulled correctly by the GetGridObject method when I click them, but it seems like the method for modifying the values on the grid cubes seems to still be based on an X,Y grid. I've been trying to figure out exactly where I need to modify it for my purposes and I think it's under the HeatMapVisual scripts and under the UpdateHeatMapVisual method, but I can't seem to figure it out. Any help would be appreciated.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Sounds like you may have an issue with either your Mouse world position or how you convert world positions into grid positions. Add a bunch of Debug.Logs to see what the code is doing You can inspect my Factory Sim game which is in 3D and uses this to see how it works kzread.info/dash/bejne/amyXq7iLZK6vj7Q.html

  • @Bmacorr

    @Bmacorr

    3 жыл бұрын

    @@CodeMonkeyUnity Thanks will do!

  • @Bmacorr

    @Bmacorr

    3 жыл бұрын

    @@CodeMonkeyUnity Just an FYI. As suspected it was an error on my end where I had misspelled a reference to the Z axis, and I also forgot to move my 3D plain to the same height as the grid so that the raycast had something to hit. It works well now!

  • @rileybazan9747

    @rileybazan9747

    Жыл бұрын

    how did you make the heatmap 3d, did you render the meshes so they're were cubes? I tried that, and couldn't figure it out, so I ended up spawning cube objects instead.

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

    Which video has the events added to grid. I missed it.

  • @Challenger.55
    @Challenger.5511 ай бұрын

    Could you please elaborate if I was to add grid component to my terrain how can this make it easier then this approach ?

  • @rogeriosartori5644
    @rogeriosartori56444 жыл бұрын

    The type or namespace name 'Func' could not be found (are you missing a using directive or an assembly reference?), How to fix it?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    On the top of your file add: using System;

  • @IronOreAgate

    @IronOreAgate

    3 жыл бұрын

    @@CodeMonkeyUnity Thank you!!

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

    When you changed to GetGridObject, how did your Visual Studio change the other references to it? Mine didn't do that, I had to do them manually, but the way yours worked is obviously way better.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    The default shortcut for Rename is Ctrl + R + R It renames all instances of the selected function/class/variable

  • @lukehughes6943

    @lukehughes6943

    2 жыл бұрын

    @@CodeMonkeyUnity May be the most valuable thing I've learnt so far! Love your work

  • @josevalenzuela4540
    @josevalenzuela45404 жыл бұрын

    Dont know why after define the TGridObject in the Grid script, now Unity does not show the lines (yet the bool values) from 6:12

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

    Thanks for the wonderful tutorial! I do have a question however, why is this grid system better than the tile map system unity provides? I'm still a beginner to unity and have only made one Snake game haha so I still have much to learn. Thank you!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    The Tilemap system is meant for positioning visuals, whereas this system is meant for holding logic or any data in each grid position. For example later on in this series each Grid Object holds a reference to the Building that is placed on it or if it's empty. unitycodemonkey.com/video.php?v=dulosHPl82A The regular Tilemap system isn't meant to hold that kind of logic, only visuals. unitycodemonkey.com/search.php?q=grid

  • @PureNrGG

    @PureNrGG

    Жыл бұрын

    @@CodeMonkeyUnity Thanks for the response! This is so beyond my ability right now as I just started learning C# and Unity like 2 weeks ago. Luckily I know C and Java so I'm able to semi understand, but holy hell this is a lot haha but I'm learning so much from this tutorial!!

  • @HorizoneMeNol
    @HorizoneMeNol3 жыл бұрын

    7.47 I follow all step i need to cancle out heatmapvisual to make it use-able and my heatmap bool visual can change into true but not turning green

  • @GameWithAshish58
    @GameWithAshish588 күн бұрын

    Hello, I've been working on developing a 2D farm system for my game, but I've hit a roadblock and could really use some guidance. I've been stuck on this for about a month now and would greatly appreciate any help or advice you can offer.

  • @jonahblack2000
    @jonahblack20002 жыл бұрын

    Question, I used these before while making a 2D game (pathfinding), but right now I am in a time crunch and want to use this grid system in 3D. I am trying to make a VR drawing "tablet" (A board) on which you draw "spell runes" and then it would compare with a library which I would create to see if there are any familiar runes and do the proper spell. I figured using your grid would be the best solution, as I can draw easily and add custom values to it, (for comparing afterwards). But I am not sure how to make the grid in 3D space and if it is possible to attach it to a game object (and if it would rotate with it). Or how to just spawn it in a certain direction.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    I've used this grid system in 3D in several videos, you mainly just need to change X,Y for X,Z unitycodemonkey.com/video.php?v=dulosHPl82A unitycodemonkey.com/video.php?v=gkCBCCKeais Although in your case it sounds like the spells are actually 2D or do you include depth in your spell drawing? Usually spell drawing is 2d only So for your use case I think it would be similar to how I did the pixel art system unitycodemonkey.com/video.php?v=Rfoyh3GOhOE

  • @jonahblack2000

    @jonahblack2000

    2 жыл бұрын

    @@CodeMonkeyUnity the spell drawing grid is 2D (for simplicity for spell recognition). I just don't know how to move or rotate the 2D grid in a 3D enviroment (as in, could I attach the grid to a game object so the parent's transform affects the grid (so the grid would be facing the player). I know I could set the origin point to a empty GO which would be attached to the drawing tablet. But when the grid is created it uses world space, not local space, right? Also the grid itself is not a game object and therefore doesn't have a transform so it can't rotate I guess?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    ​@@jonahblack2000 You need to use some math to convert world positions in the board where you're drawing the spells. How are you detecting touches on the board? You have some location position where you touched on the board, use that to convert into a grid position. I'm not much of a mathematician, for me it's usually trial and error but that's where I'd start.

  • @jonahblack2000

    @jonahblack2000

    2 жыл бұрын

    @@CodeMonkeyUnity Yeah I figured it would be something like that. I was hoping maybe you've done that already (If I manage that in a timely manner I will do that and send you the results, but for now I will "draw" using LineRenderers (cause I get info that I can compare 2 images with) as I am stressed for time. The way I would detect touches is by raycast hit/ collider collisions /onTriggerEnter. Alrighty then, thanks for your help

  • @BrunevaStudios
    @BrunevaStudios4 жыл бұрын

    This tutorial was very confusing for me. When you change the Grid class to hold a generic type, the HeatMapVisual class shows a bunch of errors, and while you do fix them by creating HeatMapBoolVisual script and going over whats wrong, it is not clear why you can test the original map with all those errors, since you haven't created HeatMapBoolVisual yet. I've been cracking my head trying to fix them and it just won't work.

  • @collinfarrell9718

    @collinfarrell9718

    3 жыл бұрын

    I had the same issue. I just commented out that entire script. I'm guessing during editing maybe some little details like that get left out sometimes.

  • @unnamedsettler9540

    @unnamedsettler9540

    3 жыл бұрын

    @@collinfarrell9718 I know I'm really late to this, but I don't think you were wrong for commenting it out. at 6:22, he has the beginning of a block comment (the /*) right at the start of his script above "private Grid grid;" in Unity's Inspector window, and I can only assume he ended it after everything, since it shows majority of the code and I didn't see the ending comment mark in it.

  • @warrenklassen1130

    @warrenklassen1130

    2 жыл бұрын

    I had the same issue but the real problem was that you originally reference GRID, when he introduces generics the format changes to GRID so GRID will no longer find it. If you change all references of GRID to GRID in the HeatMapVisual class it then works again.

  • @jwalkaz6097
    @jwalkaz60973 жыл бұрын

    I know this is old but at 6:00 when you skip from code to playing, The heatmap visual script gives me errors so I cant actually test what we did. the error says The type name 'OnGridValueChangedEventArgs' does not exist in the type 'Grid'

  • @aldenmauro2227

    @aldenmauro2227

    3 жыл бұрын

    I was able to fix this by adding the type of the grid after each Grid in the code. There were two spots not covered in the video where you have to add the type. E.g.: Grid.OnGridValueChangedEventArgs e, changed to, Grid.OnGridValueChangedEventArgs e.

  • @aquan11111

    @aquan11111

    3 жыл бұрын

    @@aldenmauro2227 Thanks man

  • @MalikenGD
    @MalikenGD4 жыл бұрын

    Bit of a programming noob here, but do generics work with DOTS/Burst?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Yup it should work just fine.

  • @JunneaXroc
    @JunneaXroc4 жыл бұрын

    Thank you for the excellent tutorials I've been following for a year now! One question: when you edit the code at 6:37 you get these wiggly lines under the OnGridValueChanged stuff and you don't show how you're fixing that, but still at 7:35, you run it without errors. When I follow along, I get this error: "Assets\GridMap\Scripts\HeatMapBoolVisual.cs(37,62): error CS0426: The type name 'OnGridValueChangedEventArgs' does not exist in the type 'Grid'". Line 37 is "private void Grid_OnGridValueChanged(object sender, Grid.OnGridValueChangedEventArgs e) " (because I like to put the { on a new line). Could you explain what is going on?

  • @JunneaXroc

    @JunneaXroc

    4 жыл бұрын

    ... never mind. If compared my code with yours and found that I also needed to put behind the Grid there. Missed that when following along. Sometimes it goes very fast! :-)

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Glad you found the solution!

  • @duckslayr

    @duckslayr

    4 жыл бұрын

    @@CodeMonkeyUnity I was having this problem too, it makes it hard to follow when you fast forward all the code entry, you type ridiculously fast as it is, this is just impossible to catch all of at times.

  • @gabrieljt.3062

    @gabrieljt.3062

    3 жыл бұрын

    @@JunneaXroc behind which Grid? I still can't fix that issue

  • @JunneaXroc

    @JunneaXroc

    3 жыл бұрын

    @@gabrieljt.3062 Hmmm I don't think I remember for sure, but I think there's a reference to a grid somewhere that should have had behind it. It's been months and a global pandemic ago :-| What I do remember is that I ran my code against Code Monkeys and saw differences. Hope that helps.

  • @TheAnonymPL
    @TheAnonymPL4 жыл бұрын

    How can I get just the generic grid from package?

  • @MirjamvanM
    @MirjamvanM3 жыл бұрын

    Just wondering.. is there a way to start the grid in the left upper corner? So 0,0 and as example to put the last 9,6 in the right bottom corner

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Sure, when you have all the math related to position, instead of doing +y do -y

  • @Brian-fp8kp
    @Brian-fp8kp2 жыл бұрын

    In the end of the video I had errors when trying to get a position out of grid. I also double checked with your code files. It seems that you forgot something? I fixed it with a nullcheck in the testing class though. Maybe there is a better solution? What do you suggest :)? if(Input.GetKeyDown(KeyCode.A)) { _grid.GetGridObject(GetMouseWorldPosition())?.AddLetter("A"); } if (Input.GetKeyDown(KeyCode.B)) { _grid.GetGridObject(GetMouseWorldPosition())?.AddLetter("B"); }

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Yup a simple null check works

  • @ArmaanVB
    @ArmaanVB4 жыл бұрын

    I'm using the grid for a building system. I can select an object and click on the grid and it builds it and sets the tile to occupied. However, I cant figure out how to make it work with objects that would take arbitrary tile sizes such as 2x3, 4x9 etc. how do I mark all those tiles as occupied instead of only the one i clicked on? * Assuming the objects already know their own size Thanks

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    When you're adding it to the grid do a cycle going through the width and height of your object and fill those up. So instead of modifying the grid directly make a function that takes the object type and X Y position, normally I use the Lower Left corner of the object as its origin So if my object is 2x2 then I make a function that takes X, Y and occupies X, Y, X + 1, Y + 1

  • @ArmaanVB

    @ArmaanVB

    4 жыл бұрын

    @@CodeMonkeyUnity Thanks! that got it working great! Now for removing a placed object I'm storing a list of TileObjects it occupies on each object so when I click remove on the object it sets all tiles in that list to unoccupied. Is there a better way to do this?

  • @devangmakwana5277

    @devangmakwana5277

    3 жыл бұрын

    @@CodeMonkeyUnity can you please make video on this

  • @sonicherores
    @sonicherores4 жыл бұрын

    Hello Again Love your tutorials but I run into a small problem with HeatMapGenericVisual When I replace the bool with HeatMapGridObject It freaks out telling me it does not exist I event went and compared with the project files and it still gives me an error telling me it HeatMapGridObject could not be found any idea where I messed up?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Sounds like you dont have the HeatMapGridObject class in your project, download the project files related to the Heat Map kzread.info/dash/bejne/n46uvLqfqbbLdrQ.html

  • @sonicherores

    @sonicherores

    4 жыл бұрын

    @@CodeMonkeyUnity Hello, I have got the HeatMapGridObject class inside my testing and I get no errors on it as well but when I try to get it on the generic visual part it states it doesn't exist which is where the confusion begins the class is set to public but I can still not get a reference to it sorry for the noob questions!

  • @paulcavey7494

    @paulcavey7494

    4 жыл бұрын

    I am guessing you have not dragged the new generic heat map game object into the testing objects script. Or you have not set the grid in the start() of the testing script to set it. Eg heatMapGenericVisual.SetGrid(grid);

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

    How are you able to access HeatMapGridObject in defined in the Testings script from HeatMapGenericVisual when you don't have a reference to Testing? Maybe it's because I'm using a different version of Unity but mine doesn't allow this.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    You mean the Grid using the Object class defined in Testing? The Grid receives a Generic type, it doesn't care where that type is defined, it just uses the object type it is given.

  • @collinfarrell9718

    @collinfarrell9718

    3 жыл бұрын

    @@CodeMonkeyUnity Sorry, no I meant when writing code in HeatMapGenericVisual the editor wasn't recognizing HeatMapGridObject without first writing Testing.HeatMapGridObject. It makes sense that I had to do that I just though it was strange that your editor didn't force you to write "Testing." before "HeatMapGridObject" but mine did. Not really a problem just a curious observation. Thanks for the tutorial.

  • @foamtoaster9742

    @foamtoaster9742

    3 жыл бұрын

    @@collinfarrell9718 In his code, the HeatMapGridObject class is outside of the testing class. I am guessing that in your code you wrote the HeatMapGridObject class inside the testing class which meant you had to write Testing.HeatMapGridObject

  • @themirlabs
    @themirlabs4 жыл бұрын

    im not sure if im backwards or something but that hardest thing for me so far has been building a mesh in code. i didn't get it that well and ended up using your script for it. i still dont get whats going on in there at all though.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    It is a bit confusing at first but when it clicks it all makes sense. Go slowly step by step and play around with the code. First try to make a simple untextured polygon. So manually position 3 vertices and 3 triangles. Then play around with the vertices to see the polygon change and play around with the triangles to see how if you put them counter clockwise the mesh will be facing backwards. Once you understand how a simple triangle works you know everything you need to expand upon it. A quad is just two triangles merged together.

  • @silentsammiee
    @silentsammiee3 жыл бұрын

    Hello, Im new to coding but I realy love it, 1 question. I tried my best to copy your code and when im testing at 7:35, yours turn green while mine stays black. are there any possible mistakes in my part?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Does it turn from False to True? Use Debug.Log to verify that you're calculating the correct mouse position and grid position

  • @silentsammiee

    @silentsammiee

    3 жыл бұрын

    @@CodeMonkeyUnity yes, im pretty satisfied with just having the inteded result. sooner or later, I am continuing to your series until the heatmap video. Thanks for replying even the video is long ago.

  • @vincentphillips2933

    @vincentphillips2933

    2 жыл бұрын

    @@CodeMonkeyUnity Same problem as @Silent Sam Plays. I've followed everything to a T and still no success. The only way I could ever get it to work was to create a 2nd grid script specifically for the color changing based on the heatmap but with debugging turned off. Then in the testing script create the 2nd grid in the same exact position with exactly the same dimensions and specs. Instead of calling SetValue from the Grid class in the grid script. I had to call AddValue from the Grid class created with the heatmap video(The 2nd grid script specifically for color changing). Is this the way you made it work? //Variables [SerializeField] private HeatMapVisual heatMapVisual; [SerializeField] private HeatMapBoolVisual heatMapBoolVisual; private Grid grid; private Grid gridBool; // Start is called before the first frame update void Start() { grid = new Grid(20, 10, 15f, Vector3.zero); gridBool = new Grid(20, 10, 15f, Vector3.zero); heatMapVisual.SetGrid(grid); heatMapBoolVisual.SetGrid(gridBool); } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Vector3 position = UtilsClass.GetMouseWorldPosition(); grid.AddValue(position, 100, 100, 1); gridBool.SetValue(position, true); } } From the video it doesn't show this yet yours still works as intended by changing not only to True but also to green. However in the video you do disable the original HeatMapVisual GameObject. Whenever I do this mine surely doesn't work. The only way I get the same results as you at this point is by doing what I stated. Was this just a cheeky work around that I did? Is my thinking completely off? Any replies are greatly appreciated.

  • @ThaDewey

    @ThaDewey

    2 жыл бұрын

    For me, it was the eventHandler. I had commented it out since at the beginning of the video because off all the errors i was getting. so do you debuts and check to see if the EventHandler is firing as it should

  • @aegisdota_
    @aegisdota_11 ай бұрын

    Hey! There was an issue that Func statement at 10:25 wasn't recognizable by compiler, I solved it just adding System.Func instead of simple Func. I don't understand why it should be like this... If someone says, it would be nice

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    11 ай бұрын

    Func exists inside the System namespace so it's just because you don't have "using System;" on top

  • @aegisdota_

    @aegisdota_

    11 ай бұрын

    @@CodeMonkeyUnity So stupid issue... I should have notice that, anyway TY, and for great tutorials too!

  • @adkinsy85
    @adkinsy854 жыл бұрын

    You are so cool 😎👌

  • @zodi4991
    @zodi499110 ай бұрын

    @CodeMonkeyUnity I've been trying to fix a problem I have with debugs and all but I cant get to find what cause this. When I click the text number doesnt update to its new value, however with debugs I found out that the value does change on the click. Do you know why?

  • @zodi4991

    @zodi4991

    10 ай бұрын

    I've followed everything up to 16:35, and it seems to be the exact same as you however my text doesnt visually update to their new values and stay at 0

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    10 ай бұрын

    Are you sure you're modifying the correct object? Are you calling TriggerGridObjectChanged with the correct XY? Add DEbug.Log's on every step of the way to see which part is failing, maybe you're not changing the right XY, maybe the debugs are not updating, maybe you're not correctly getting the ToString();

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

    you have the videos are out of order. you have this as the second video in the sires, but you say we should watch the 4th video in the series before we fallow this one. so I think you should put this in a better order. I apresheat all the work you put into these videos thank you.

  • @MrGhettoGurke
    @MrGhettoGurke2 жыл бұрын

    Hey CodeMonkey, really nice video :) But i have one question. Instead of creating a reference to the grid in the HeatMapObject, i did this: if (gridTestObject != null) { { gridTestObject.AddValue(5); grid.SetGridObject(gridTestObject.x, gridTestObject.y, gridTestObject); } } This works, but is this a valid solution?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Sure, but what exactly are you doing? It seems like you're not creating all the grid objects during construction but rather only when setting the value. So all grid objects will be null until they have a value in them, is that your goal? It works but it seems like a needlessly confusing way to do it.

  • @MrGhettoGurke

    @MrGhettoGurke

    2 жыл бұрын

    @@CodeMonkeyUnity I tried to encapsulate the Grid from the TestObject. But nvm, i figured out how to use the event system to raise an event, and than listen to that event in the grid. But thank you for the fast response :) But now i have an other question. Can i transform the grid into an isometric grid?

  • @Ryan-ww7un
    @Ryan-ww7un2 жыл бұрын

    There's already a grid class in Unity. How did you handle the conflict?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    That built in class does not support generics so as soon as you implement generics there's no more conflict

  • @Wispii
    @Wispii2 жыл бұрын

    Been following the video till 17:02, and my code is now telling me that in the test script that SetGrid(grid) "Cannot convert from "Grid" to "Grid"", as well as saying that the type or namespace of "HeatMapGridObject" could not be found in the generics script. I checked through your code and all of my code lines up, yet i'm getting the error.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Sounds like you're using 2 different types, one just HeatMapGridObject and another one named the same but inside another class named Test

  • @MrNintendeion
    @MrNintendeion3 жыл бұрын

    I don't want to do any of the heatmap stuff as I'm trying to just implement A* into my turn based strategy game, this code seems unfollow-able though without having implemented all the heatmap stuff, can I follow this tutorial without doing the heatmap coding?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    The heatmap is just a visual so yes the grid works with or without it

  • @josephwilkins238
    @josephwilkins2384 жыл бұрын

    My code still doesn't update the numbers the second time you ran it. I think it is something to do with the OnGridValueChanged object as it doesn't seem to get set at all during the project so it is left as null meaning the code won't run. It doesn't get mentioned that much in any of the videos so I have no clue what to do.

  • @josephwilkins238

    @josephwilkins238

    4 жыл бұрын

    Ok. I figured out what to do there is a few lines of code at the bottom of setting up the grid this is the code for anyone with the same issue: OnGridValueChanged += (object sender, OnGridValueChangedEventArgs eventArgs) => { debugTextArray[eventArgs.x, eventArgs.y].text = gridArray[eventArgs.x, eventArgs.y]?.ToString(); };

  • @PleasureofaDream

    @PleasureofaDream

    Жыл бұрын

    I also ran into this issue but seem to have a different solution. I spent almost an hour debugging before realizing I forgot to assign the x and y values inside the constructors. This seems to be a common thing I forget when following along, to remember to assign inside any new variables added to the constructors.

  • @futurewitness9162
    @futurewitness91622 жыл бұрын

    Hi, around the 17 minute mark where you change the grid type from bool to HeatMapGridObject I start getting errors. My grid was working perfectly up until then with the bool type, but when I try to switch to the HeatMapGridObject Grid I get a namespace error; CS0246 The type or namespace name 'HeatMapGridObject' could not be found (are you missing a using directive or an assembly reference?) I have no idea what to do about this or how to fix it. I'm completely stumped. I have noticed that HeatMaprGridObject also exists in the Testing Class, but am unsure if that affects anything as in your video you didn't change them (or show you changing them). The only things I did differently to you in the video is not rename all of the "GetValue"s, would that change anything? I also commented out the entirety of the first heatmap and bool scripts as they were causing clashes and were no longer being used as far as I could tell.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    It simply means you don't have anything in your project named "HeatMapGridObject" I made the heat map here kzread.info/dash/bejne/n46uvLqfqbbLdrQ.html

  • @futurewitness9162

    @futurewitness9162

    2 жыл бұрын

    @@CodeMonkeyUnity I've already completed that tutorial. I finished it with no errors and followed it up with this one. Should "HeatMapGridObject" be present somewhere in the script as a variable that I just missed? I've been comparing my scripts with yours in the utilities and been using that to fix my minor errors, but you don't have a HeatMap script in there so I have nothing to compare my HeatMap scripts to outside of the video.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    @@futurewitness9162 It's been a very long time since I made this video so I don't remember everything I did in it but that class was created in the Heat Map video and the error you're seeing is because it expects that class to be present in the project Alternatively you can download the project files for the videos later on in this playlist which will have the entire Grid class more polished kzread.info/head/PLzDRvYVwl53uhO8yhqxcyjDImRjO9W722

  • @steevdavis1421

    @steevdavis1421

    2 жыл бұрын

    @@futurewitness9162 If it helps I was stuck on this too and just worked out the 2 things I had missed out. Your Testing script needs "heatMapGenericVisual.SetGrid(grid);" inside of Start() *and* your HeatMapGridObject class needs to be *outside* of the Testing class but in the Testing script. ie, make sure all your }s are fully closed off before you declare the HeatMapGridObject. Hope this makes sense and helps.

  • @PleasureofaDream

    @PleasureofaDream

    Жыл бұрын

    @@steevdavis1421 Thank you! This fixed it for me. Mine was inside the class!

  • @madhackademy3558
    @madhackademy35583 жыл бұрын

    i must say with only 3 years in coding the "Func createGridObject" blow up my mind and i honeslty would work with a simple struct for one purpose in my case the path finding. I think it could work too . I m wrong i m right i dont know. Now i feel like i m in a sand box and playing with my poop. Dont get me wrong this is rly good stuff. But i think with this grid system i will not be able to adapt in my use case or Sadly follow with the DOTS or ECS version you made. I suppose your chanel is out of my league. See ya

  • @joyoussuccess
    @joyoussuccess3 жыл бұрын

    Cool Heatmap in Unity is video #2 .. i think..., the playlist is out of order

  • @NotOfficiallySeanHD
    @NotOfficiallySeanHD3 жыл бұрын

    So I followed everything in the tutorial just fine. but I don't get the black background? I've checked my Z and it's fine. I got the black background on the bool visual but for some reason not this one. It doesn't seem to be firing my updateHeatMapVisual part. but if I run "heatMapGeneric.SetGrid(grid);" it gives an error of: NullReferenceException: Object reference not set to an instance of an object How would one fix this?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Use Debug.Log to figure out exactly what object is set to null. Do you see a black object in the Scene view? If so then its something with the camera, if not then its something with the grid.

  • @olegentzsch3301

    @olegentzsch3301

    3 жыл бұрын

    If u are still missing a solution. U might have just forgotten to assign your HeatMapVisual GameObject to the Serialized Field HeatMapVisual in the Unity Editor :)

  • @bosshauggin6920

    @bosshauggin6920

    3 жыл бұрын

    @@olegentzsch3301 For anyone else running into this issue this resolved it for me! Thank you!

  • @abdou023
    @abdou0232 жыл бұрын

    My current project doesn't show the value on the map when I click on a tile. I just need to show the value without all the heatmap, event triggering stuff. Is there a simpler way?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Are you working on a 3D game? The method for getting the mouse position is different kzread.info/dash/bejne/Yp6Isq2zY8rHZNo.html

  • @abdou023

    @abdou023

    2 жыл бұрын

    @@CodeMonkeyUnity Thank you for replying. There is no problem with the mouse position. I was just asking if there is a simpler way to display the value rather than using the event handler or basically the entire heatmap section of this tutorial.

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

    i have a query can we use this grid system in UI to make a map and map it to our 3d world space?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    I'm not sure I understand your question, translate world positions into a UI map? Sure that could work. Alternatively you can just use the simple minimap method unitycodemonkey.com/video.php?v=kWhOMJMihC0

  • @wasifalmeem4651

    @wasifalmeem4651

    Жыл бұрын

    @@CodeMonkeyUnity im actually working on a 2d map similar to Decentralands map and i have used your grid building logic with the 3d environment and its working amazing now i wanna do the same thing but on UI in such a way that the sprite for Map is used to get the mouse current postion on that specific map sprite and from there map those coordinated to 3d world space

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

    Guys, please help me. When i'm trying to do the same, i get the error Grid' does not contain a definition for 'GetGridObject' and no accessible extension method 'GetGridObject' accepting a first argument of type 'Grid' could be found (are you missing a using directive or an assembly reference?) I dont know what to do.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Looks like you're passing in the Grid reference as a parameter to GetGridObject instead of the position

  • @magictimm4090
    @magictimm40903 жыл бұрын

    Followed your video until 17:30. You said "debug mode is off". Is this the reason for having numbers instead of colors in the grid? I cannot find the error in my code. It runs correct. But I have no colors.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Your quads should be receiving their correct color on UpdateHeatMapVisual(); Add a Debug.Log to make sure that function is running and maybe a log on a specific position (0,0) and click on it to see if it changes

  • @magictimm4090

    @magictimm4090

    3 жыл бұрын

    @@CodeMonkeyUnity Thank you. I added heatMapGenericVisual.SetGrid(grid); and now I have the correct number 0 (5,10...) and the correct color in the quad. But in your video the number is not shown. I used the code from your website in a separate testing project. And it's the same result. Number and color. It's not a big issue but it would be interessting whats the reason for this.

  • @HorizoneMeNol

    @HorizoneMeNol

    3 жыл бұрын

    @@magictimm4090 how did you do it ?

  • @magictimm4090

    @magictimm4090

    3 жыл бұрын

    @@HorizoneMeNol Sorry, cannot find the code

  • @JaKayne

    @JaKayne

    2 жыл бұрын

    Add "heatMapGenericVisual.SetGrid(grid);" at the end of the Start method in the Testing class and it works fine. It is not shown in the video.

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

    So many times i run into errors because scripts dont compile.. I go over the video again and dont see how you solve it. Like how heatmapvisual was working in your first test and making grid generic. My scripts had tons of errors.. You solved these errors off "camera"?.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    What errors? Without knowing the text it's impossible to knw the cause. Maybe you just don't have a package installed?

  • @bryceblazegamingyt9741
    @bryceblazegamingyt97413 жыл бұрын

    Hello! Im having a problem at 5:52, after I change the Grid, to Grid. It gives me 'Cannot implicitly convert type 'Grid' to 'UnityEngine.Grid' Am I missing something?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Sounds like your code is trying to use the built-in Unity Grid instead of the one created in this video

  • @bryceblazegamingyt9741

    @bryceblazegamingyt9741

    3 жыл бұрын

    @@CodeMonkeyUnity Wow thanks! I didn't expect a reply. This video is pretty old.

  • @bryceblazegamingyt9741

    @bryceblazegamingyt9741

    3 жыл бұрын

    I was able to fix the error by replacing "Grid grid = new Grid(PARAMS);" with "Grid grid = new Grid(PARAMS);"

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

    I am getting an error for the Func: Assets\Scripts\Grid.cs(16,84): error CS0246: The type or namespace name 'Func' could not be found (are you missing a using directive or an assembly reference?) No idea why that isn't working. Also not missing any assemblies that I know of. Why wouldn't this be workin?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    You need "using System;"

  • @TheIronicRaven

    @TheIronicRaven

    Жыл бұрын

    @@CodeMonkeyUnity 🤦‍♂️ it's always the simple stuff that gets me 😆 thanks a million! Love your vids!

  • @TheIronicRaven

    @TheIronicRaven

    Жыл бұрын

    @@CodeMonkeyUnity Are there more references you are using that aren't shown in the video? I was able to get along until the event system and then I am missing another assembly reference. It looks like your code has a lot of them, but they are cut off from the screen.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Like what? This is the second video, did you watch the first grid system video? Also you can download the project files to look at all the source code

  • @TheIronicRaven

    @TheIronicRaven

    Жыл бұрын

    @@CodeMonkeyUnity hm, that is odd. I followed the first video and it worked perfectly! Not sure why this one is giving me reference errors. I'll see if I can download the files and root through them!

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

    Im getting an error on 7:39 about null reference. NullReferenceException: Object reference not set to an instance of an object Grid`1[TGridObject].SetValue (System.Int32 x, System.Int32 y, TGridObject value) (at Assets/Scripts/Grid.cs:88) Grid`1[TGridObject].SetValue (UnityEngine.Vector3 worldPosition, TGridObject value) (at Assets/Scripts/Grid.cs:96) Testing.Update () (at Assets/Scripts/Testing.cs:21) Can't figure it out. Also how do I get the texture for the material? Thanks

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Use Debug.Log to find what is null unitycodemonkey.com/video.php?v=5irv30-bTJw You mean the background texture? I grabbed it from the asset store, don't remember which one, there's thousands of free textures.

  • @Ziron2008
    @Ziron20088 күн бұрын

    I did this one very different due to removing grid Events + LateUpdate from heatmap for performance. Even a constant bool check indefinitely isn't good in an update. I've learned a long time ago to avoid putting things in Update threads. That is how you achieve prime optimization. This is the main part that matters to show how to avoid this. You could technically still use an event for this part and just don't use the lateupdate for the other part I mentioned in the heatmap video. Either way, nothing in updates unless it's input logic. Even then, it would probably be better to use the new input system Unity created for this very reason. public void TriggerGridObjectChanged(int x, int y) { SetValue(x, y, gridArray[x, y]); } public HeatMapGridObject(Grid3D grid, int x, int y, HeatMapGenericVisual hmgv) { this.grid = grid; this.x = x; this.y = y; this.hmgv = hmgv; } public void AddValue(int addValue) { value = Mathf.Clamp(value + addValue, MIN, MAX); grid.TriggerGridObjectChanged(x, y); hmgv.UpdateHeatMapVisualGeneric(); }

  • @theoriginalmakaaka101
    @theoriginalmakaaka10128 күн бұрын

    You have magic code in the video that is never revealed as to its addition to the grid.cs. At 6:04 is the line. "debugTextArray[x, y] = UtilsClass.CreateWorldText(gridArray[x, y]?.ToString(), null, GetWorldPosition(x, y) + new Vector3(cellSize" is all we can see but the creation of that line is never shown in any of the videos in the creation of that script. Therefore, how can the audience know what the end of that line is? As there is no link to say "Find out how to remove the error message by typing in the actual code".

  • @theoriginalmakaaka101

    @theoriginalmakaaka101

    28 күн бұрын

    For those that got stuck on the same problem, here is the missing code that is required for the script to function: debugTextArray[x, y] = UtilsClass.CreateWorldText(gridArray[x, y]?.ToString(), null, GetWorldPosition(x, y) + new Vector3(cellSize, cellSize) * .5f, 30, Color.white, TextAnchor.MiddleCenter);

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    27 күн бұрын

    You can download the project files linked in the description or just my utilities class if you want to read the whole source code. It just does exactly what the function says, it spawns a World Text object on that position.

  • @mrmogelost6720
    @mrmogelost67203 жыл бұрын

    How come you've already created tutorials for almost everything I could wonder about??!!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    That's my goal! With 400 videos I've already covered quite a bit, imagine when I get to 1000!

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

    I downloaded the Codemonky Utilities but it's missing MeshUtils. Anyone know why? I don't want to learn mesh right now as it's a lot to learn. I'm stuck on this now.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    The MeshUtils aren't part of the regular utilities, I made those in a separate mesh based video although I don't remember exactly which one. If you download the project files for a recent project it will be there, for example this one unitycodemonkey.com/video.php?v=XqEBu3un1ik

  • @atqamz
    @atqamz6 ай бұрын

    in my unity there's no MeshUtils.CreateEmptyMeshArrays method, what cause this happen?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    6 ай бұрын

    That's not a built in class, that's something I built. I don't remember which specific video I made that first, you can download the project files for this video or look at the mesh video unitycodemonkey.com/video.php?v=11c9rWRotJ8

  • @Nikhil-eg9zc
    @Nikhil-eg9zc4 жыл бұрын

    1st like and comment, Yaaayyyyy

  • @nkemer
    @nkemer3 жыл бұрын

    Although great content and playlist, I think there is a continuity problem with this video. The code on the screen doesn't match with the code at the end of the previous video. If copy and paste then no problem but if you follow the code, it is not good. Full of error messages.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Yes this "series" wasn't ever planned to be a series, I just made a Grid System then kept upgrading it over time so there are some things I made offscreen since I never planned on making this many videos on it.

  • @Vulpiro
    @Vulpiro3 жыл бұрын

    5:46 I changed everything but after change to Generics i got error in testing class

  • @stephenperry1006

    @stephenperry1006

    3 жыл бұрын

    What error message are you receiving? If you've already solved the problem, nevermind!

  • @dewalderasmus6205
    @dewalderasmus62052 жыл бұрын

    I have done everything and it works perfectly until I came to 16:33 - 17:38 I'm not sure what I did but it just shows that same as 16:33 I have no errors and it works but I don't get the heatmap visual. I went over it again and again and I feel like I'm missing something obvious but I'm not sure what it is. I also finished the tutorial and downloaded and looked over the files. for some reason evything works for me but the heatmap.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Is the heatmap behind the camera? Or maybe it's there but not changing color so it's always black?

  • @dewalderasmus6205

    @dewalderasmus6205

    2 жыл бұрын

    @@CodeMonkeyUnity no not behind or always black just no color. At least I don't think it's behind because I can see the numbers fine when I enable Debug.log

  • @dewalderasmus6205

    @dewalderasmus6205

    2 жыл бұрын

    for now I'm just going to continue on with the other tutorials and come back to this one when I have to implement the heat map. I started this journey because I wanted to place down building in a grid in game with prefabs. and unity's tile maps do not allow that. But now that I have the tile map I have a million other things I want to add to it later that I didn't even think about before.

  • @RRaiho

    @RRaiho

    2 жыл бұрын

    @@dewalderasmus6205 Try to set the HeatMapGenericVisual in the start merthod HeatMapGenericVisual.SetGrid(grid);

  • @Grimbly44

    @Grimbly44

    2 жыл бұрын

    @@RRaiho @Raiho Rai Had the same issue as Dewald, tried your soltion, works like a charm Thanks Raiho! Shoutout to Code monkey as well for all these tutorials!

  • @hoxtober9879
    @hoxtober98793 жыл бұрын

    I can't get access to the Utils, cause e-mail verification is not working at the web site. Anyone had such problem? Any advice could help!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Check your spam folder

  • @hoxtober9879

    @hoxtober9879

    3 жыл бұрын

    @@CodeMonkeyUnity Thx, mail was storde in another section :/

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

    I have to watch these at .25 speed to understand 😅

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Yup, take your time! Remember that it took me a long time to learn all of this, certainly longer than the video length.

  • @blameyourm8519
    @blameyourm85192 жыл бұрын

    What is heatmap for in games?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    You can use it to display stats in a map, like where players get the most kills Or use it to build a tool to see where your player clicks The Heatmap is just a visual, it's up to you to decide what data it uses.

  • @AmgedAlfakih
    @AmgedAlfakih11 күн бұрын

    So how to make the grid folow the parent rotation??

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    9 күн бұрын

    This grid doesn't have the concept of a parent, it just has an origin position. Although sure you could make the origin the same as some kind of parent object, and use some math to apply rotation to all the grid positions based on the parent

  • @AmgedAlfakih

    @AmgedAlfakih

    9 күн бұрын

    @@CodeMonkeyUnity so what is the calculation for this, any idea or article??

  • @edubyou
    @edubyou7 ай бұрын

    Why is this second in the playlist when it uses so much Heatmap? that not for two more episodes - its really odd. Great instructions but not explaining where stuff came from is hard to piece together. I'm doing mine in a 3D environment and I intend to use some physics so I had to change y for z but I might just have hit a wall as in comes vector2's oh shit.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    7 ай бұрын

    That's because this series of videos wasn't planned ahead of time, I just started building a GridSystem and kept building upon it, so some things are out of order. The GridBuildingSystem video has downloadable project files and is in 3D unitycodemonkey.com/video.php?v=dulosHPl82A

  • @edubyou

    @edubyou

    7 ай бұрын

    @@CodeMonkeyUnity thanks so much. I kept watching through to late in the series and things are making a lot of sense now. Good idea to just watch these for the approach and then play with it after in Unity. Great content good sir.

  • @micaiahstevens8840
    @micaiahstevens88404 жыл бұрын

    Was a bit confused, thought you had to define your custom type; in this case TGridObject. However it seems the Generic knows since it starts with T or something you are creating a Generic. I was mistaken somehow. Its not QUITE clear in the video how you came up with this Variable, name type object thingy!

  • @micaiahstevens8840

    @micaiahstevens8840

    4 жыл бұрын

    Might try and make a link to a XY grid and a XZ grid, its always frustrating when people make a screen grid vs a ground grid. I get why they would do it, but in a 3D it doesn't make much sense. (NOTHING to say that this Screen Grid facing the screen isn't helpful or useful especially in your games.) I wish was some sort of projection matrix, or way to slice the ground grid, and use a single Z as your Y in your Screen grid.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    You just define the name for the type, it can be anything you want, normal naming convention is to start generics names with T Putting it inside is what tells it that it's a generic.

  • @micaiahstevens8840

    @micaiahstevens8840

    4 жыл бұрын

    Thanks very much. Did over an hour and a half reply video, BUT ended up writing the TileGeneric, probably should not steal your thunder. I imagine your is going to be MUCH flashier than mine. Although talked about a basic Tile Editor as well.

  • @twobits7310
    @twobits73104 жыл бұрын

    I am a bit confuse about this decoupling and dependency thing(I listen about decoupling and dpd but i never implement these concepts). Otherwise am good programmer and i understand every single line of your code.

  • @monfis112
    @monfis1122 жыл бұрын

    I do not understand purpose of HeatMapGridObject, it creates circle dependency.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    How so? The heat map was made in this video kzread.info/dash/bejne/n46uvLqfqbbLdrQ.html

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

    what is override?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    You "replace" the virtual function in the base class

  • @Robster881
    @Robster8812 жыл бұрын

    You really need to re-order these. I'm trying to follow along and you start talking about things in the code you've not covered yet in the playlist.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    This series wasn't planned ahead from the start, I just started building the grid and improving upon it. So there's no 100% step by step path like in my courses

  • @juliendev2191
    @juliendev21914 жыл бұрын

    I know the video is really old already, but why don't I just make a grid of structs ?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Because most of the times it's much more useful to store an object rather than simple data.

  • @juliendev2191

    @juliendev2191

    4 жыл бұрын

    @@CodeMonkeyUnity oh, okay, what about holding a scriptable object ? I'm new to unity so I'm trying to figure out some clean ways of coding things in this engine :)

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

    I just wanna make an A* pathing algorithm 😭

  • @xxbongobazookaxx7170

    @xxbongobazookaxx7170

    3 жыл бұрын

    Same, I've done it in python ages ago but C# is so confusing to me still

  • @danielleanderson6371
    @danielleanderson63719 ай бұрын

    I wish you wouldn't edit out all the little details you change off screen. It's really hard to follow what you're doing when I have to keep stopping to figure out why I have an error and you don't. I get that generally the issue is just that I need to comment something out, but a half second of visual confirmation would stop me from second-guessing myself all the time. Edit: I'm more lost than ever. Somehow I lost the mesh entirely, so I don't get black squares, let alone green, and now I have to leave for work. Was really hoping I could make headway on this this morning, but it seems I've broken something trying to follow your dubious editing.

  • @jiwkis
    @jiwkis8 ай бұрын

    For me to understand a specific video, I need to travel between several videos. I would like to learn the content of video 12, but he recommends watching video 1 and 2. In video 2 he recommends watching video 4 first, all of this is a huge mess.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    8 ай бұрын

    This "series" wasn't planned ahead of time, I just started building a grid system and then kept building on top of it, and then some applications (like the Building System and Heat Map) are forks and not sequels so yeah it can be a bit messy. If you're looking for a step by step guide then I recommend you follow my TBS course, in there I use a Grid System like this one kzread.info/dash/bejne/g4qYrdCElsq1erw.html

  • @TheGreenLing

    @TheGreenLing

    8 ай бұрын

    @@CodeMonkeyUnity Thanks for linking to this very helpful!

  • @sodanakin
    @sodanakin3 жыл бұрын

    Puts Terrarria in title proceeds to not give the example how you could use it for a terrarria like game.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    The Grid can represent anything you want. Use it to represent a Ground tile, add the logic to destroy it as well as build it and you have Terraria.

  • @sodanakin

    @sodanakin

    3 жыл бұрын

    @@CodeMonkeyUnity I got that far but how to procedural generate all the tiles on the grids and do i generate new grids as chunks?

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

    Ffs, why use stuff from other tutorials such as heatmap that you didn't show to implement in the first one. :/

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Because this wasn't planned ahead of time, I just built interesting systems and kept building upon it. If you're looking for a guided step-by-step then look into my TBS course where I do use a Grid System and build it all step-by-step unitycodemonkey.com/courses.php?c=turnbasedstrategy

  • @VerzatileDev

    @VerzatileDev

    11 ай бұрын

    @@CodeMonkeyUnity Understandable, but still feels there should be some guidance ( I know " oh just go look for it " ), but at the same time it makes me leave the channel and I do like your content most of the time, but its just feels more of a dev-log than how to do it, but that is understandable you never called it a tutorial. Just think overall I'd make videos first utilize the content in the code you are making and then later in the video it could be added to utlities I may be wrong of course! (Considering my videos are nothing of good either I cannot tell you how to do it).

  • @oleksiiliaskovskyi5381
    @oleksiiliaskovskyi53814 жыл бұрын

    Pleaseee, don't use speeding up. Its so confusing when you can't understand what's going on and when code part is huge I get lost with your tutorial.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    You can pause the video at any time and download the completed Project files from the website.

  • @tgdwarf

    @tgdwarf

    3 жыл бұрын

    @@CodeMonkeyUnity Its a good thing that you do, keep the tempo high for when you just want the explanation of the code, but don't the specifics, as you say, can always download or pause to see it.

  • @ZmastaZz
    @ZmastaZz3 жыл бұрын

    I got confused in these fucking videos what comes after?