Cool Heatmap in Unity

✅ Get the Project files and Utilities at unitycodemonkey.com/video.php...
Let's take our Grid System and add a colored Mesh on top based on the underlying values in order to create a cool looking Heatmap effect!
You can see this effect in action in the Environment Overmap in Battle Royale Tycoon
store.steampowered.com/app/85...
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 ...
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

Пікірлер: 269

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

    Here's a really cool effect! It builds upon the previous videos that covered the Grid Map and Custom Mesh. You can see this effect in action in the Environment Overmap in Battle Royale Tycoon store.steampowered.com/app/851930/Battle_Royale_Tycoon/

  • @theforce9953

    @theforce9953

    Жыл бұрын

    Seriously Code Monkey? I found your channel and decided I would use your videos to learn. Now because of your antics, like so many self proclaimed "indie devs" on youtube, I'm looking elsewhere for someone who is truly serious about teaching others how to code. I followed your video for creating a custom grid class. I wanted to make sure I understood everything so going through that 23 minute and 43 second video took me several hours. Then I come to this video and within the first four minutes of this video the code you show for the grid class is different from the point where you left off from the last video where you introduced it. One example: "public event EventHandler OnGridValueChanged; public class OnGridValueChangedEventArgs : EventArgs { public int x; public int y; }" What does that do and why is it there? There were other changes I could see before you started typing more code for the grid class at 3 minutes and 50 seconds. If this is how your videos are going to work then they're useless to me. I'm not interested in downloading the project/code related to your videos and copying your code so I can lie and tell others, "Look what I did." When all I did was copy your code. I'm interested in learning how it works and understanding it so I can do it myself and adapt/pivot it for my purposes. So many youtubers do this nonsense of adding code in they don't explain. Many of these self proclaimed "indie devs" will often make videos with titles that claim they will show a viewer how to do some complex task but they obviously don't go over all the code. If people want to put up videos showing perspective employers they know how to code good for them; and they should title it accordingly and not lead people on that actually want to learn.

  • @Mendogology

    @Mendogology

    4 ай бұрын

    @@theforce9953 Wow, you are really as small sad man, aren't you?

  • @darcking99
    @darcking992 жыл бұрын

    In case you don't have "MeshUtils" in the project, I stared strongly at the screen for 2 hours and made these two methods that replicate "AddToMeshArrays" and "Create EmptyMeshArrays", at least for this case should be enough. You may have to fix the mesh position tho. private void AddQuad(Vector3[] vertices, Vector2[] uvs, int[] triangles, int index, Vector3 GridPos, Vector3 QuadSize, Vector2 Uv) { vertices[index * 4] = new Vector3((-0.5f + GridPos.x) * QuadSize.x, (-0.5f + GridPos.y) * QuadSize.y); vertices[(index * 4) + 1] = new Vector3((-0.5f + GridPos.x) * QuadSize.x, (+0.5f + GridPos.y) * QuadSize.y); vertices[(index * 4) + 2] = new Vector3((+0.5f + GridPos.x) * QuadSize.x, (+0.5f + GridPos.y) * QuadSize.y); vertices[(index * 4) + 3] = new Vector3((+0.5f + GridPos.x) * QuadSize.x, (-0.5f + GridPos.y) * QuadSize.y); Debug.Log(vertices[0]); Debug.Log(vertices[1]); Debug.Log(vertices[2]); Debug.Log(vertices[3]); uvs[(index * 4)] = Uv; uvs[(index * 4) + 1] = Uv; uvs[(index * 4) + 2] = Uv; uvs[(index * 4) + 3] = Uv; triangles[(index * 6) + 0] = (index * 4) + 0; triangles[(index * 6) + 1] = (index * 4) + 1; triangles[(index * 6) + 2] = (index * 4) + 2; triangles[(index * 6) + 3] = (index * 4) + 2; triangles[(index * 6) + 4] = (index * 4) + 3; triangles[(index * 6) + 5] = (index * 4) + 0; } private void CreateEmptyMeshData(int quadCount, out Vector3[] vertices, out Vector2[] uvs, out int[] triangles) { vertices = new Vector3[quadCount * 4]; uvs = new Vector2[quadCount * 4]; triangles = new int[quadCount * 6]; }

  • @AlonBru

    @AlonBru

    Жыл бұрын

    HERO

  • @nemogames5354

    @nemogames5354

    Жыл бұрын

    Real G

  • @simon9036

    @simon9036

    10 ай бұрын

    Dude this is so clutch- thank you. I would like to ask you how to change the mesh position though, the code is working and putting all of my meshes in a grid formation but they are far too spread out. I've been trying to manipulate your code to change the position but I'm not exactly sure which part is doing the shifting. I've tried removing and changing a lot of the values but could really use a bit of help 🙏 thank you again for this

  • @simon9036

    @simon9036

    10 ай бұрын

    NVM - I got the legit functions that do not require fussing with: public static void CreateEmptyMeshArrays(int quadCount, out Vector3[] vertices, out Vector2[] uvs, out int[] triangles) { vertices = new Vector3[4 * quadCount]; uvs = new Vector2[4 * quadCount]; triangles = new int[6 * quadCount]; } ------------------------------- public static void AddToMeshArrays(Vector3[] vertices, Vector2[] uvs, int[] triangles, int index, Vector3 pos, float rot, Vector3 baseSize, Vector2 uv00, Vector2 uv11) { //Relocate vertices int vIndex = index*4; int vIndex0 = vIndex; int vIndex1 = vIndex+1; int vIndex2 = vIndex+2; int vIndex3 = vIndex+3; baseSize *= .5f; bool skewed = baseSize.x != baseSize.y; if (skewed) { vertices[vIndex0] = pos+GetQuaternionEuler(rot)*new Vector3(-baseSize.x, baseSize.y); vertices[vIndex1] = pos+GetQuaternionEuler(rot)*new Vector3(-baseSize.x, -baseSize.y); vertices[vIndex2] = pos+GetQuaternionEuler(rot)*new Vector3( baseSize.x, -baseSize.y); vertices[vIndex3] = pos+GetQuaternionEuler(rot)*baseSize; } else { vertices[vIndex0] = pos+GetQuaternionEuler(rot-270)*baseSize; vertices[vIndex1] = pos+GetQuaternionEuler(rot-180)*baseSize; vertices[vIndex2] = pos+GetQuaternionEuler(rot- 90)*baseSize; vertices[vIndex3] = pos+GetQuaternionEuler(rot- 0)*baseSize; } //Relocate UVs uvs[vIndex0] = new Vector2(uv00.x, uv11.y); uvs[vIndex1] = new Vector2(uv00.x, uv00.y); uvs[vIndex2] = new Vector2(uv11.x, uv00.y); uvs[vIndex3] = new Vector2(uv11.x, uv11.y); //Create triangles int tIndex = index*6; triangles[tIndex+0] = vIndex0; triangles[tIndex+1] = vIndex3; triangles[tIndex+2] = vIndex1; triangles[tIndex+3] = vIndex1; triangles[tIndex+4] = vIndex3; triangles[tIndex+5] = vIndex2; }

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

    If anyone was having problems implementing the EventHandler OnGridValueChanged from the end of the first video (grid system) in the series, check out 3:37 of the video, lines 55 - 57 of the code. On the first 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 of this video, OnGridValueChanged got updated to a non-null value.

  • @potatoes131

    @potatoes131

    3 жыл бұрын

    This helped me perfectly find the bits I was missing. Thank you so much.

  • @winterscrap4806

    @winterscrap4806

    3 жыл бұрын

    Thank you, this saved me a lot of time and frustration

  • @christinaVennegerts

    @christinaVennegerts

    3 жыл бұрын

    Thank you very much!

  • @dough254

    @dough254

    2 жыл бұрын

    i still got problems

  • @deslaya7777

    @deslaya7777

    2 жыл бұрын

    you are scholar and a saint good sir

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

    Thanks for the great tutorial. A nice implementation would be to use this in Influence Map like system (for RTS games). The difference basically would be to have a constant update to the grid changes and instead of "add values by range / radius" would have a method to catch the neighbors using parameters like influence, decay and momentum.

  • @oliverdowning1543
    @oliverdowning15433 жыл бұрын

    Surely a better heat map would define the radius as x^2+y^2 instead of x^y so as to create circles not diamonds and actually use distance rather than a rough and rather inaccurate approximation of it in the shape of a diamond. I know for a circle you can't use the four triangles trick but if you change all the terms in the triangle to be x^2 and y^2 instead of just X and y you can just as easily make a quarter circle. This would increase the overall size of the shape but to counteract this you can either input smaller x and y values or you can square root the x and y before using them so as to balance everything out. It isn't necessary for all use cases and it is a little more computationally expensive but I thought it worth mentioning because it is better for certain things on account of better showing distance from a point on the diagonal.

  • @Qupear
    @Qupear4 жыл бұрын

    Thank you very much. This content is very helpful.

  • @biyagames8698
    @biyagames86984 жыл бұрын

    I'm very excited for the next lesson thanks!!!

  • @aaronedvalson104
    @aaronedvalson1043 жыл бұрын

    I'm really glad you optimized it at the end with LateUpdate(). I went from 18s to instant change. There's an issue which you had in this video that you might not have noticed when posting it, but maybe you know of it now. It's that there's an outermost cell that subtracts. You can't see it unless you make two heatmaps overlap. Sorry if you've addressed it since this video, I'm coming from the mesh and grid vids. But hopefully anyone who sees will know it's not their fault. Lol Edit: Apparently, it has to do with the values for the grid and the AddValue() method. Not sure why it is, but when I downscaled everything the issue went away.

  • @CodingWithUnity
    @CodingWithUnity4 жыл бұрын

    Super cool video!

  • @evilplantosavetheworld
    @evilplantosavetheworld3 жыл бұрын

    I get to the 25 minute mark and my code is running so slow I spent a good hour going over the video over and over and googling things to find where I screwed up. Apparently my screw up was not just ignoring the performance issue and continuing on to where you explain how to fix the performance issue.

  • @hidemat5141

    @hidemat5141

    3 жыл бұрын

    Well this comment saved me a lot of googling. Thanks. LateUpdate() for the win!

  • @EntropicalNature

    @EntropicalNature

    3 жыл бұрын

    Same here!! I was wondering why it went so slow and then I read this! Great comment! :)

  • @bencollom2513

    @bencollom2513

    2 жыл бұрын

    omg im so glad i read this

  • @lance5005

    @lance5005

    2 жыл бұрын

    I was literally just about to do this. Thanks for saving me time with the comment lol

  • @JonathonMcClung
    @JonathonMcClung3 жыл бұрын

    Hey man, thank you for your tutorials. Just a small request though, could you organize the playlist these are in the order we are supposed to do them in? I initially sought out the pathfinding one and it took me a bit to realize that the order is Grid>Heatmap>Generics>Pathfinding. I think it might help out future learners if the playlist was in the correct order and maybe if the videos were numbered? Thanks for taking the time to read this.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    The order is tricky since I didn't exactly plan for all these videos to be part of one continuous order, I just covered various topics and used the Grid class when it made sense. This Heatmap is just a nice visual so technically not exactly necessary for making the Pathfinding work but it is used in the demo.

  • @JonathonMcClung

    @JonathonMcClung

    3 жыл бұрын

    @@CodeMonkeyUnity Yeah, I tried to skip it and do the Generics one but there was code in that one that relied on code done in the heatmap video. At least, it seems so to the best of my comprehension.

  • @JonathonMcClung

    @JonathonMcClung

    3 жыл бұрын

    @@CodeMonkeyUnity Also, if you get a chance I am trying to verify my email on your website so I can download your utils, but I am not receiving the email. I double checked the spelling and it is correct. And it isn't showing up in spam or anything. Not sure if I am the only one or not, you might want to check it out.

  • @damionmccoy9966

    @damionmccoy9966

    2 жыл бұрын

    @@JonathonMcClung me too its still an issue apparently, I hope he fixes soon becuase I would like the utils and the MeshUtils

  • @Steak514

    @Steak514

    11 ай бұрын

    Ya, the logic from one video to the next doesn't match, meaning it can't be followed. I never would have even thought to check out generics and also didn't think I needed heat map. Thanks for posting the correct order.

  • @Randomguy-op2hs
    @Randomguy-op2hs Жыл бұрын

    Beatiful!! god damm, before the performance fix at the end my computer nearly killed itself when i clicked to create heatmap XD

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

    If someone have the problem at 12:50 that the mesh isnt black. If you used a URP template to start the Unity Project the material need the Universal Render Pipeline/Unlite Shader (select the Mateial "Black Red Yellow Green" and in inspector on the top you can change it

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

    I love these tutorials so thanks so much for creating them! Would it be possible to show the setup of your game because I struggle sizing everything to fit in the window when in Game mode. In the video it also appears that you can scroll your game view? I don't see reference to anything specifically but it would be nice to follow along and be able to navigate and see exactly what you're showing. Thanks again!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    You mean moving the camera in Battle Royale Tycoon? I covered a camera system here unitycodemonkey.com/video.php?v=pJQndtJ2rk0

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

    thank you !!!

  • @Jason-wh3mq
    @Jason-wh3mq3 жыл бұрын

    I feel like I'm missing a video. Somewhere between this video and the "Grid System in Unity (Heatmap, Pathfinding, Building Area)" there were code additions to the Grid script. There's a new place where the text only shows on the grid if a bool is set to true. And the event and event handlers that was quickly mentioned in the Grid video, but wasn't really gone into. What video am I missing?

  • @DoubleOBond

    @DoubleOBond

    3 жыл бұрын

    I too am having this issue. Around 3:27 you can see where there is a bool showDebug that was added with an If statement around the previous code, but more importantly, where does the OnGridValueChangedEventArgs even come from? If you know the answer, please respond.

  • @gabrieljt.3062

    @gabrieljt.3062

    3 жыл бұрын

    I had a similar problem with the "EventArgs" that was added maybe offcamera, but i fixed that just by adding "using System;" on top of anything

  • @dusklights6810

    @dusklights6810

    2 жыл бұрын

    @@gabrieljt.3062 Lifesaver!

  • @vytautassaule4220

    @vytautassaule4220

    2 жыл бұрын

    @@DoubleOBond if you follow the video carefully, you can find some code that was added off-camera. what I did is just pause on places that were different than in the previous video and write it down, also trying to understand where it comes from, and what it does.

  • @lethn2929
    @lethn29294 жыл бұрын

    You have no idea how helpful this is to me, I was doing months of research on how to do borders for maps like you have in RTS' and this popped up, I know this is a long shot but does anyone have any idea of how you could implement this for 3D terrain?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    The logic would work the same, just replace XY with XZ. The visual will also work easily if your plane is flat but it does become a lot more tricky if you have uneven terrain. For that maybe look into projections and project the heat map texture onto the terrain.

  • @lethn2929

    @lethn2929

    4 жыл бұрын

    @@CodeMonkeyUnity Oh fuck! Thanks for the fast reply, now I have new stuff to look up too, I'll check it out and see what ways I can implement this.

  • @1lsgaming27

    @1lsgaming27

    4 жыл бұрын

    @@lethn2929 I actually gave up on adding borders to my rts over a year ago because i couldn't find a way to do it. Now because of you commenting I think i might try again, so thanks and thanks code monkey

  • @lethn2929

    @lethn2929

    4 жыл бұрын

    @@1lsgaming27 if you're curious as to how I did my effect, in the end I chose spheres with a stencil buffer effect so that the spheres would keep a consistent border. forum.unity.com/threads/how-to-keep-consistent-colour-transparency.757814/#post-5047784 I have yet to implement anything fancy yet but I'm looking into it. The guy who responded to my thread did a very helpful explanation of the problem I was looking at. Unfortunately at the moment Unity shader graph doesn't have a stencil buffer node of any kind that I'm aware of so you have to write your own shaders for this method.

  • @1lsgaming27

    @1lsgaming27

    3 жыл бұрын

    @@lethn2929 thanks this was helpful!

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

    Hello there, first of all many thanks for these very helpful videos! I noticed that when I change the cell size of the grid to for example 1.0f and change the font size to e.g., 2, the values still update but the colours of the heatmap do not. Do you have any idea why this is happening? Thank you!

  • @annekim7940
    @annekim79404 жыл бұрын

    Thanks for video! Can it be used for visualizing the most active zones on the touchscreen?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Yup absolutely, just increase the value in the underlying grid position whenever the player touches the screen.

  • @Ghin_Antonic
    @Ghin_Antonic3 жыл бұрын

    IDK how you tested that right away with such a massive radius, when I tried that legit froze for what felt like half a minute while it computed the requested action. Didn't crash, but any kind of freezing like that is terrifying at times.

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

    That would be great if you can show us how to do this in a Hex Grid too. (Following new Hex grid tutorials) Thank you for this great content!

  • @ReddLolz
    @ReddLolz4 жыл бұрын

    cool video. can you make a tutorial on thermal vision and how to equip and unequip it at runtime

  • @zekiozdemir420
    @zekiozdemir4202 жыл бұрын

    thank you

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

    Hey! love the tutorials, thanks for all your hard work. Quick question -- I dowloaded the Utils from your site and I don't see the MeshUtils. Were those changed or deprecated since this video was made?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Yeah those have "Utils" in the name but they're not part of the general utilities, they're a special class that I made in some mesh video and include it in most projects. So if you instead download the project files for this one it should be there

  • @xenaedits551

    @xenaedits551

    Жыл бұрын

    @@CodeMonkeyUnity Amazing, thanks for the quick reply!

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

    Hi thanks a lot for this video. i got a question. why you said in first 5 places after the spot that we clicked we have a 100 value, it's clearly 3 places above or bellow the spot. also how we decrease value by 6? in every level!

  • @cakeu
    @cakeu4 жыл бұрын

    Hello codemonkey! I've been following your grid tutorials and i've already done your first tutorial, and i'm at this episode from now, but i have an issue; At around 10:45 you're refferencing "grid.GetHeight()" and "grid.GetWidth()" which i haven't seen until now. Am i missing something? I wasn't able to make those myself.

  • @cakeu

    @cakeu

    4 жыл бұрын

    Also i'm not able to download the project files for this tutorial, when i enter your website it redirects me to a page telling me: "Failed to download file!"

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    The grid is a int[,] array so to get the width you do gridArray.GetLength(0) and to get the height you do gridArray.GetLength(1); I'll look into the issue with the downloadable project files, thanks!

  • @cakeu

    @cakeu

    4 жыл бұрын

    Ok so i managed to finish the tutorial after that, but i have one last problem; I'm getting a whole lot of lag when generating the heatmap with a grid.AddValue(position, 100, 5, 40); , and by that i mean when clicking i get like 15s of lag, how do i fix that?

  • @doylelewis5523

    @doylelewis5523

    3 жыл бұрын

    For those who are coming from the grid video and have missed the changes that allow the GetWidth() and GetLength() to work. It is simply a function added in the grid script that allows you to access the private variables of length and width. In the Grid Script after the class template add the functions: public int GetWidth(){ return width; } and public int GetHeight(){ return height; }. You can also add the public float GetCellSize() {return cellSize;} for good measure if you like. That will fix your issue without having.

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

    Would this line of grid tutorials be useful in making a grid tactics game like Fire Emblem? I've gotten through the the first video and a bit of this one but I've noticed that some of the future videos on grid stuff are geared more towards games like Xcom and I don't know how well it translates. In the meantime I'll keep going at it because I'm still learning a lot of new stuff doing these.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Yes, I made that specific scenario quite a long time ago kzread.info/dash/bejne/n4OCqtecn7yng7g.html And more recently I've been working on a 3D XCOM-like, still haven't finished that project but I did some development during a livestream kzread.info/dash/bejne/eISIprqiiryslco.html So yup this grid is perfect for that genre

  • @futurewitness9162

    @futurewitness9162

    2 жыл бұрын

    @@CodeMonkeyUnity Thank you for replying so quickly. Do you think it would be feasible to make something like this following these tutorials? Just as a vague estimation of what I'm hoping to do. kzread.info/dash/bejne/f4KHs7mJmMTSd7Q.html&ab_channel=AngusFan

  • @greengamesindie7220
    @greengamesindie72203 жыл бұрын

    Hey, I´m thinking about how to track my player on a heatmap and give this information to an Overview map. The main question i´m asking is how do you think would it be possible to visulize the position of the player an a Overviewmap ? And thanks for your nice Videos dude !

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    You could constantly reset the entire grid to full black and on every frame print the new player position

  • @hakanviajando
    @hakanviajando2 жыл бұрын

    Hi, thanks for the videos, the mesh utils and the gradient file is not found in the website. Do we need to be a patreon to access those?

  • @phildonahue3158

    @phildonahue3158

    2 жыл бұрын

    Until the project files for this video get fixed, you can find meshutils inside the project files of this video kzread.info/dash/bejne/amyXq7iLZK6vj7Q.html

  • @hakanviajando

    @hakanviajando

    2 жыл бұрын

    @@phildonahue3158 thank you

  • @FerusDeus
    @FerusDeus4 жыл бұрын

    In some cases, heatmap overlaping on other meshes and creates a broken heatmap. For ex: grid = new Grid(500, 100, 1f, Vector3.zero); There are many more like this one. Increasing the X and Y values increases the overlap of meshes. Do you have a solution for that? Im not familiar with creating meshes like you. Thank you.

  • @xoinf

    @xoinf

    3 жыл бұрын

    I have exactly the same problem. Did you found any solution ?

  • @ascode2films691

    @ascode2films691

    2 жыл бұрын

    same here

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

    Hi, in which video we can see how you set up the very beginning of this project? I'm referring to the camera moving using your keyboard and the background. Thanks a lot for your sharing attitude!!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    I think in this one I was still using my old Camera System kzread.info/dash/bejne/h2pquLuGXbbOhso.html Nowadays I just use Cinemachine kzread.info/dash/bejne/f6Bs0taHlcjgo7g.html

  • @9adamlevin
    @9adamlevin Жыл бұрын

    I'm stuck on CalculatePath, how come the endNode has anything assigned to its cameFromNode when currentNode == endNode and you send it to CalculatePath? For me endNode just contains null and only the last node gets added to the final path.

  • @hiagorlindo
    @hiagorlindo4 жыл бұрын

    thank you very much for the video, i managed to understand, but i would like to know how i change the black background for a transparent one

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Either don't draw anything when there's nothing there or use a transparent texture. Check out the video on using this Grid to make a TileMap kzread.info/dash/bejne/mXhpp7OypJq8gM4.html

  • @jiangan1545

    @jiangan1545

    4 жыл бұрын

    I have met the same problem.I want to draw a heat map on a picture.How did you do it?

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

    Hey, thanks for making these tutorials! The MeshUtils seen in this video seem to be missing from the utils package on the website, is this intentional?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Yeah MeshUtils isn't part of the regular Utils, it's something I made in one of these mesh videos but can't remember exactly which one. So it's not in the utils but it is included in the project files. I think the last time I used it was in the Hex Grid System unitycodemonkey.com/video.php?v=XqEBu3un1ik

  • @AlonBru

    @AlonBru

    Жыл бұрын

    @@CodeMonkeyUnity Thanks so much for the quick reply, Ill be sure to check it out!

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

    Thanks! Does it possible put a random texture in cell instead of text?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    What do you mean? You want to place a different texture in each Grid cell? Sure that is possible, that's essentially how the Tilemap works.

  • @yaroslavmakarov2218

    @yaroslavmakarov2218

    4 жыл бұрын

    Yes, thanks for answer! So in general, i should make a squads mesh, and use tilemap for putting sprites in cells?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    @@yaroslavmakarov2218 The code shown in this video is essentially a Tilemap, you can see each grid cell is represented with a quad. The only change you need to make is the current code is only showing one pixel from the texture whereas from a Tilemap you would want to display a specific part from your Texture Atlas. Currently working on a Video adding Generics to the GridMap then I will cover a proper Tilemap.

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

    So for the most part I have this working but was very confused for a while because the black / colored mesh is under my background while the numbered text and gizmo lines are above it. Any idea as to why the background is above the mesh?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Depends if you're working in 3D or 2D. In 3D, just move them close to the camera, life the colored background a tiny bit like 0.01 on the Y In 2D, play around with Sorting Layers and Sorting Order unitycodemonkey.com/video.php?v=5_BwFB-1dAo

  • @badrballish9328
    @badrballish93283 жыл бұрын

    I love you tutorials sir, thank you very much.

  • @jonathanbarone1257
    @jonathanbarone12573 жыл бұрын

    Hi there! I have a problem with this. I am trying to always display a 100x100 pixel texture. But I don't understand how to set the last two "uv" vectors of "MeshUtils.AddToMeshArrays". some clue? the texture is represented to me only with the color of a small border, leaving out the rest of the image. thanks!

  • @jonathanbarone1257

    @jonathanbarone1257

    3 жыл бұрын

    Solved: First vector2 take values(0,0) and second vector2 take (1,1). Another think: In the video you can positioned the mesh in the origin of the drawed grid adding (+ squadsize * 5f), but i need to multiply for strange values this... 0.32f forx axis and 0.2167 (wtf) for y axis. my cells take 0.4 x 0.4 of size. do you know whats happens?

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

    Is it possible to have multiple grids which behave separate from each other? After working through this tutorial I added a method to reset all the grid values to their initial state. However when I implement the method, it resets all the grids. Is this because my multiple grids inherit from the same base class, Grid?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    The Grid is a C# object, if you call new Grid(); twice you have two objects, if you modify one it won't automatically modify the other

  • @lakemonstergames32

    @lakemonstergames32

    Жыл бұрын

    @@CodeMonkeyUnity Ah I see, it may then be something with my reset method. Thank you for the reply!

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

    Can someone explain at 11:37 : when we are creating "AddToMeshArrays( )" we are not returning anything nor we have "out" parameter, so how does code at 12:40 work?

  • @Sekunri

    @Sekunri

    2 жыл бұрын

    Way late but the out means it's returning that variable. Technically you can return multiple variables that way. The variable itself is set within the AddToMeshArrays method and whatever it's final value is becomes the output.

  • @losfouad2014
    @losfouad20142 жыл бұрын

    Hi! thanks for this awesome tutorial ! but i still don't know in which scenario we could use a heatmap , if some one can give some more examples on where to use it that would be awesome, thanks again!

  • @darcking99

    @darcking99

    2 жыл бұрын

    there are examples in the video

  • @gianlucaanostini5818
    @gianlucaanostini58184 жыл бұрын

    my mesh is black i tried to recalculate normals but it didnt work and even if i remove the texture and use a simple diffuse it doesnt change color whatever color i choose it always black. nb i alto setted the material to both faces to see if it was just turned the wrong way but its still black

  • @gianlucaanostini5818

    @gianlucaanostini5818

    4 жыл бұрын

    found the issue i hand to change to this cachedQuaternionEulerArr[i] = Quaternion.Euler(0, -i, 0);

  • @CarlKidwell
    @CarlKidwell4 жыл бұрын

    A sort of big critique of this video is that in the previous video you went to hyper speed fast forward for the last several minutes showing some basic HeatMap features and claimed you would go through it all in this video. Now that I'm going through this video I find that I have not completed those hyper speed steps and they are indeed necessary to complete this video. So yes I downloaded your package and am copy pasting code to catch up but honestly I would rather if you are going to offer tutorials to take the time to cover that material .. that is now a gap that I have copy pasted and my understanding of what happened in between is much lower. Big gaps in understanding can lead to problems later. Thank you for the videos and tutorials in general quite excellent but I wanted to offer this feedback as you may not be aware this could cause a lot of beginner programmers to not be able to follow along and lose context/give up as they may not understand why it goes bad at this point - and may not understand the package importing may fix it for them.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    What part did I not cover? I normally only speed up the part where I'm writing code but I always try to explain before/after what I'm doing/did.

  • @CarlKidwell

    @CarlKidwell

    4 жыл бұрын

    @@CodeMonkeyUnity Thanks for the follow up and reply. in this video kzread.info/dash/bejne/qZV51amuXZCfgJs.html at the 20:55 mark you note you will "quickly show several potential uses for this" at which point the video goes into fast forward mode. At the conclusion of fast forward you demonstrate basic heat map. Afterwards the next video in the series is this Heat Map video we are commenting on here. You begin this video with all the items in the fast forward section already complete and do not cover them. The only way to get those items in the code was either to go back and pause the video carefully or pull down the source from your project. So my point is - for that fast forwarded section 20:55 on - you implemented several things including EventHandlers for example that you did not go over. As someone following a tutorial video those gaps start becoming confusing. Again I appreciate your vids and content - just trying to help convey that gaps like that can be painful for someone continuing on the next video and then all of a sudden things don't match and not sure why. This could be the point some people end up frustrated and stop.

  • @williamleebuckley

    @williamleebuckley

    4 жыл бұрын

    @@CodeMonkeyUnity The code we inherited from the last video lacked many of the Gets. GetWidth, GetLength, GetCellSize, etc. Pretty easy to make, but there's always the concern you missed some bit of logic that you may or may not have added. Dunno if you're still looking at old comments, but for what its worth, I'd second the previous critique. I'm extremely grateful for your videos, and they are among, if not the, best resources for people at my level. That said, I lack your level of knowledge, expertise, and familiarity with these scripts, so I find the speed-ups almost entirely unwelcome. They force me to pause, frequently, and disrupt my personal learning by breaking the flow with the video. I would encourage you to do fewer of them, at least when you're dealing with more beginner/early intermediate videos such as the delegates/events things. That's obviously just my opinion, and more advanced folk may really appreciate the condensing.

  • @prefeituramunicipal113
    @prefeituramunicipal1133 жыл бұрын

    What is inside GetQuaternionEuler method?

  • @davetothemax3845
    @davetothemax38453 жыл бұрын

    I followed your steps exactly, but when it came to the point where the mesh was first rendered in unity as the black box offset from the grid, mine didn't show up because for some reason the Mesh mesh isn't getting assigned to the MeshFilter. I'm not getting any errors that stop me from running it, it just says that the mesh variable isn't being used anywhere (which makes no sense). Can anyone help?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Do you have some other code unassigning it? Is your mesh reference null? After you assign meshRenderer.mesh do a Debug.Log to ensure it was set correctly.

  • @davetothemax3845

    @davetothemax3845

    3 жыл бұрын

    @@CodeMonkeyUnity I’ve double checked and it still just says that the variable mesh of HeatMapVisual has not been assigned. Is there a way I can manually set it as the mesh material for the MeshFilter?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    @@davetothemax3845 The MeshFilter only contains the mesh, no material. Material is on the MeshRenderer

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

    Hey man, do you cover how to scan the whole grid in one of these videos?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    What do you mean by scan? The grid is just a 2 dimensional array so you can cycle through the whole X and Y and do whatever you want.

  • @lachnload8723

    @lachnload8723

    3 жыл бұрын

    Code Monkey Code Monkey hi! Sorry I used the contructs of the universe to allow me to find my answer. Aka, I asked you and the. Immediately found my solution afterwards, it always happens like this. But I do have another question: do you cover optimising in this series?

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

    @CodeMonkeyUnity Hello, in this tutorial around 12:50, my grid appears and the individual squares seems to be the right size, however they are extremely spaced out with huge gaps between each of them. Do you have an idea why?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    11 ай бұрын

    Are you using a texture with some transparency? Either the quads arent being positioned correctly or they are but the texture is half transparent. You can set Scene view to Wireframe mode to see if your quads are sized correctly

  • @zodi4991

    @zodi4991

    11 ай бұрын

    @@CodeMonkeyUnity I found my problem, I was using the functions from one of the comment because I didnt have access to meshUtils. I downloaded your project and got the meshUtils and now it works great with your functions.

  • @darcking99
    @darcking992 жыл бұрын

    Was MeshUtils class removed from the download page? Can't find the class anywhere.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Did you download the utils or the project files for this project? It's not part of the general utils you download from the website, it's a separate class that is included in some projects. I made this video ages ago so I don't remember if I included mesh utils in this one but I know I included it in the Draw Mesh video kzread.info/dash/bejne/iqOuqsafeNXIYbg.html

  • @michiblk4581
    @michiblk45814 жыл бұрын

    I downloaded the code but when I change the line "new Grid(150, 100, 2f, Vector3.zero)" to anything else I get totally wrong results with broken mesh. Any idea why that happens?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Broken mesh how? What did you change it to?

  • @michiblk4581

    @michiblk4581

    4 жыл бұрын

    @@CodeMonkeyUnity for example "new Grid(300, 150, 2f, Vector3.zero)" the mesh overlaps and the triangle on the edges get ripped. Good visible with shaded wireframe. Or "new Grid(150, 100, 1f, Vector3.zero)" only the left bottom side can be filled. In general changing the cellsize wont allow to fill anything on the right side anymore. It is in an empty project with only your code and I havent changed anything else in the code.

  • @xoinf

    @xoinf

    3 жыл бұрын

    @@michiblk4581 I have exactly the same problem. Any solution found ?

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

    BTW, in my case when I click over a cell it's not increasing as 1 click. It's increasing like the click was pressing many times. Is there anything I need to set up in order to avoid repeating behavior? Thanks!!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Sounds like you're using Input.GetMouseButton(); which triggers on every Update instead of Input.GetMouseButtonDown(); which only triggers once.

  • @elturkocharro4106

    @elturkocharro4106

    3 жыл бұрын

    @@CodeMonkeyUnity Thanks a lot!!! You're right!!!

  • @blaaablooo5233
    @blaaablooo52334 жыл бұрын

    idk why but my offset of the addtomesharray pos wasnt exactly fixed by +quadsize *0.5f

  • @luka6073

    @luka6073

    3 жыл бұрын

    neither does mine, have you find the way to fix that problem?

  • @luka6073

    @luka6073

    3 жыл бұрын

    I fixed it! if somebody has the same problem just make sure of set the HeatMapVisual transform on 0,0,0

  • @existentialterror6462
    @existentialterror64623 жыл бұрын

    I don't really know if I imported the Utils wrong, but the MeshUtils do not seem to be in the package. Just a possible FYI.

  • @existentialterror6462

    @existentialterror6462

    3 жыл бұрын

    If someone has the code for the AddToMeshArrays function, or the whole MeshUtils file, that would be awesome if you could share it! Thanks in advance!

  • @ericbramble5043

    @ericbramble5043

    Жыл бұрын

    @@existentialterror6462 YES PLEASE!

  • @veltedingel
    @veltedingel2 жыл бұрын

    The last part of the tutorial where the tiles intersecting with other diamonds increased their value made the grid extremely laggy for me

  • @veltedingel

    @veltedingel

    2 жыл бұрын

    Nevermind watched the rest of the video

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

    I can"t find that part in the code, where the color changing in a mesh according to the pixel in the texture. What part do that? Thank you for the answer!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    It's the UV position, I covered Meshes in more detail here unitycodemonkey.com/video.php?v=11c9rWRotJ8

  • @Ezra00zenekar

    @Ezra00zenekar

    Жыл бұрын

    @@CodeMonkeyUnity Thank you for the answer! int gridValue = grid.GetValue(x, y); float gridValueNormalized = (float) gridValue / Grid.HEAT_MAP_MAX_VALUE; i think that code set the gridValueUV vector, and change the color. Isn't it?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    ​@@Ezra00zenekar Yes, the UV is always a normalized value so if you normalize the grid value then use that as the UV it will grab different parts of the texture based on the gridValue

  • @dough254
    @dough2542 жыл бұрын

    My event Handler ongridvaluechanged and eventargs saying could not be found. I been tryna figure it out there's a part that was skip in the mix

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    EventHandler and EventArgs exists inside "using System;"

  • @dough254

    @dough254

    2 жыл бұрын

    @@CodeMonkeyUnity thanks alot

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

    Hello! Is it possible to create a grid on surface that is not rectangle?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Sure, you could do some Raycasts and attach each vertex to whatever it hits.

  • @MaxFly1996
    @MaxFly199610 ай бұрын

    For me at 12:50 it works fine, but when i create another grid and add some tiles on it, the headmap is always under the grid. Your grassy green background is behind your heatmap. How can i sort these objects in the right order?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    9 ай бұрын

    You can modify the MeshRenderer Sorting Layer and Sorting Order through code unitycodemonkey.com/video.php?v=5_BwFB-1dAo

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

    I followed the tutorial but for some reason I cannot get the black background to show in the game side? only in scene. I've gone back and looked many times and cant seem to figure out where I've missed.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Check the Z position, the mesh might be behind the camera

  • @NotOfficiallySeanHD

    @NotOfficiallySeanHD

    3 жыл бұрын

    @@CodeMonkeyUnity Thanks a lot! Appreciate the support! :)

  • @NotOfficiallySeanHD

    @NotOfficiallySeanHD

    3 жыл бұрын

    I managed to get that working from your fix but did also notice the "white boxes" no longer showed up properly. The function works perfectly fine though with the booleans and colours work perfect but I do not see the white lines for the outlines of each box.

  • @chuckdude514
    @chuckdude5142 жыл бұрын

    For those not seeing the black mesh from 12:49, make sure your 'HeatMapVisual' gameObject from your scene is at (0; 0; 0). I could have sworn I set to that like he adviced at 6:26, but for some reason my Heatmap was located specifically at (960; 540; 0)!

  • @LordDungeon

    @LordDungeon

    Жыл бұрын

    thanks chuck, I was wondering why there was no black mesh after triple checking the code. You saved my time :)

  • @ri-zg7cv

    @ri-zg7cv

    Жыл бұрын

    stuck with it as well at first. initial mesh pos formula should be like this: grid.GetWorldPosition(x,y) - transform.position + quad * .5f

  • @cryptorcd9352

    @cryptorcd9352

    6 ай бұрын

    Thank you! My mesh was off by like 20% down and I was trying to figure out what I did wrong in the code lol You are the hero!

  • @cryptorcd9352
    @cryptorcd93526 ай бұрын

    Hi CodeMonkey, not sure if you are reading comments on old videos like this one, but I have one question. Hopefully it isn't too stupid. How did you figure out formula for index? x*height+y. Is there some specific resource that explains formulas like this that are useful in coding or is there some step by step logic you go through in your head when trying to figure it out? If I was doing this from scratch, I'm not sure my math is strong enough that I would figure out this is the best way to get the correct index for each cell and I'm concerned that in the future I'll get stuck on steps like this when making my own projects. I would appreciate nudge in the right direction be it coding book or some math principles I would need to know to get better at this. Thanks! I appreciate the amount of tutorials you did over the years!

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    6 ай бұрын

    That really comes with experience, it's not my first time making a flat array that represents a 2D array, so I already knew I needed to multiply one of the values by width/height and add the other one, don't think there's a special term for that equation, it's just converting a 2D array into a flat index So really the only advice I can offer is just build tons of systems and use google a lot when you get stuck, every time you create a new system from scratch you get better at problem solving, then in the future when working on a new system you will have that extra problem solving knowledge and experience from tons of systems you've made in the past. Best of luck!

  • @cryptorcd9352

    @cryptorcd9352

    6 ай бұрын

    @@CodeMonkeyUnity Thanks! That's a bit reassuring since my brain was melting trying to understand logic behind how you came up with the formula every time you wrote one. Good to know it will become easier with experience!

  • @rickbeniers667
    @rickbeniers6674 жыл бұрын

    the black mesh isn't created with me, unity is not issuing any warnings or errors and our codes are almost the same, am I missing something?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Is it really not created or just invisible? PAuse the scene and inspect the Mesh inside the MeshFilter, it should show X number of vertices. Maybe you set the UV counter clockwise so your mesh is facing away from the camera

  • @rickbeniers667

    @rickbeniers667

    4 жыл бұрын

    @@CodeMonkeyUnity thanks, I thought I already checked if it did just spawn somewhere else but I just saw that it was quite far away from the grid for some reason.

  • @rickbeniers667

    @rickbeniers667

    4 жыл бұрын

    @@CodeMonkeyUnity hey I finally found the time to continue this tutorial but when I click on the grid to change multiple squares there colour unity crashes, might this have a common explanation or is this too much to ask from unity(should be weird because rendering a few colours should not take so much effort), I have no idea what can cause this because the entire engine just stops and I can't even look at all the values on run time. did you experience this while making these videos or have some tips on how to resolve unity from freezing?

  • @edwinmacias7038
    @edwinmacias70383 жыл бұрын

    Hello. Everything works fine for me, but for some reason it is not drawing the colors, and it does not give me any error. Nice video:)

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

    I'm confused about the index on 10:54, why do we need to multiply by the height? And also plus the Y? I thought I got it for a sec, but its gone now.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    It's basically a conversion from a 2D array to a 1D array If you have an array with size [2,2] and a flat array with size [4] Then index 0 on the flat array would equal position 0,0 on the 2D array, position 1 would be 1,0 and position 2 would be 0,1 For 0,1 with a width of 2 index = 0 * 2 + 1; which equals 1 which is correct

  • @Sirpokemaniaco

    @Sirpokemaniaco

    Жыл бұрын

    @@CodeMonkeyUnity Oh yeah that makes a lot more sense now, thanks a bunch

  • @alimorgan1407
    @alimorgan14072 жыл бұрын

    Hello! great tutorial, but I have a problem.... on Testing class if I create a grid with a height less than it's width like for example : new Grid(20, 10); I get an "index out of range exception" like the one you see here: IndexOutOfRangeException: Index was outside the bounds of the array. MeshUtils.AddToMeshArrays (UnityEngine.Vector3[] vertices, UnityEngine.Vector2[] uvs, System.Int32[] triangles, System.Int32 index, UnityEngine.Vector3 pos, System.Single rot, UnityEngine.Vector3 baseSize, UnityEngine.Vector2 uv00, UnityEngine.Vector2 uv11) (at Assets/GridMap/Scripts/MeshUtils.cs:138) HeatMapVisual.UpdateHeatMapVisual () (at Assets/HeatMapVisual.cs:57) HeatMapVisual.SetGrid (Grid grid) (at Assets/HeatMapVisual.cs:23) Testing.Start () (at Assets/Testing.cs:12) ideas?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Use Debug.Log to see exactly what index is out of range, probably trying to access a position off grid kzread.info/dash/bejne/Z52m2JVpXcW6eto.html

  • @franciscokloganb
    @franciscokloganb4 жыл бұрын

    How can I create the Mesh properly in a 3D World? I've adapted your Grid code with success to a 3D Game, where the world is offset from the origin. I am, however, having trouble creating the Mesh for the HeatMap in 3D. Using the code directly makes me have the bottom half polygons of the Mesh correctly created on the XZ plane (I changed the parameters passed to UpdateHeatMapVisual#AddToMeshArrays), but the top half polygons do not render and each polygon line does not touch the next. I assumed this was because of the way you created AddToMeshArrays and indeed you used Vector3(x, y) instead of Vector3(X, 0, Z), but when I modified that, all my polygons render and touch, but they are created on the XY plane instead of the XZ. I guess it has something to do with the rotational values, but I do not understand a lot about vectors. It was always my weakness.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Check out this video where I converted the Grid System to XZ kzread.info/dash/bejne/Za6stsugmq3YYpc.html

  • @franciscokloganb

    @franciscokloganb

    4 жыл бұрын

    @@CodeMonkeyUnity Got it, it was indeed the rotation. :)

  • @unclerandy398

    @unclerandy398

    3 жыл бұрын

    @@franciscokloganb how do you fix the rotation, the rot function in mesh utils doesnt work for me.

  • @bluceree6897
    @bluceree68973 жыл бұрын

    My heatmap acts weird. It works properly with cell values from 1 to 99. Values 0 and 100 make the mesh dark green. What did I do wrong?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Make sure your texture is set to point filtering so it doesn't get compressed. You're seeing the right side of the texture bleed into the left side. Also make it Clamp

  • @bluceree6897

    @bluceree6897

    3 жыл бұрын

    @@CodeMonkeyUnity Thank you very much! It works! :)

  • @macanici8
    @macanici84 ай бұрын

    I'm at the part where the color changes with the value. Problem is that i don't get black for my 0 value. 0 and 100 share same color value (tried to shift the material offset).

  • @macanici8

    @macanici8

    4 ай бұрын

    My values were green since the beggining, when all cells should be black no matter what, cause the uv's were set as Vector2.zero.

  • @macanici8

    @macanici8

    4 ай бұрын

    Ok, i found it. On the black red etc texture, in the inspector at texture type, it was set on default instead of "sSprite (2D and UI).

  • @dankevch.8864
    @dankevch.88643 жыл бұрын

    in 8:45 , i can't drag the heat map to the variable and i don't know why? cab someone exxplain this? (unity 2020)

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Does the object you're trying to drag have the HeatMapVisual script as a component?

  • @svplatypus
    @svplatypusАй бұрын

    Pretty big longshot to see if anyone sees this but: At the very end of the video, after I make the LateUpdate method, the color gradient no longer changes. I can see the number values change but the color stays black. If I comment out the new code and go back to the slow version, the colors change. Anyone experienced this or have any idea how to fix it?

  • @davidheary2482

    @davidheary2482

    Ай бұрын

    I just found this video. I'll run through it after work and see what I get too.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Ай бұрын

    Add some logs and see waht the code is doing. Maybe you're not firing the event to update the visual?

  • @dimitarboychev5794
    @dimitarboychev57942 жыл бұрын

    OK so here I begin I checked the code 3 times and everything is right but I still get null refrance exception:object reference not set to an instance of an object. How to fix it, I have been trying for hours now and can't fix it.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Use Debug.Log to find what is null kzread.info/dash/bejne/Z52m2JVpXcW6eto.html

  • @dimitarboychev5794

    @dimitarboychev5794

    2 жыл бұрын

    It worked! Thank you so much! You are the best teacher!

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

    How did you do the WASD movement on the map?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    I covered a basic Character Controller here kzread.info/dash/bejne/dJqTl9OCpJytops.html

  • @lachnload8723

    @lachnload8723

    3 жыл бұрын

    @@CodeMonkeyUnity Thank you so much this is awesome. One of the most active youtubers i've seen in the community.

  • @lachnload8723

    @lachnload8723

    3 жыл бұрын

    @@CodeMonkeyUnity Hey so at 17:50 you cycle through the range and you use the increments "x++" & "y++". If i wanted to make a centered square could i just make a second set of for loops doing "x--" & "y--"? Seems to crash when i do so. EDIT: nvm i just mirrored it. Man i really should just watch the whole video. But i am still interested into why it crashed.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    @@lachnload8723 It probably crashed because you created an infinite loop, always be careful with your loop conditions

  • @lachnload8723

    @lachnload8723

    3 жыл бұрын

    Code Monkey Ahh that makes sense. In one of these grid videos do you show away to scan the whole grid and certain cells of it? I've gotten really close to finishing my project, but it seems right at the last part I've come to a complete stop. I scan the when grid like you did making the first square: using for loops and cycling through each cell. But that means some edits happen before others, making different edits wrong. I don't know if that makes sense but basically, is there a good way to scan the whole grid all at once (not for loops)? EDIT: Or even more specifically: is there a way for 1 cell to state it's own worldposition in a script?

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

    ive been following your grid tutorial and im trying to make it into an isometric grid. How do I make the mesh into an isometric one in the UpdateHeatmap visual?

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    You have to do some math to calculate the quad vertices positions in isometric. The easy way is to leave your game world flat and just move the camera to an isometric viewpoint.

  • @jakehix8132
    @jakehix81323 жыл бұрын

    "Bezos Mode" is a more apt name for this tutorial.

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

    why your library not sorting. im confuse to see your video -.-

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    Жыл бұрын

    Sorting? What library?

  • @STEVANUSGameDev

    @STEVANUSGameDev

    Жыл бұрын

    @@CodeMonkeyUnity youtube library. I saw your video in video 2 in library. you already add heatmap but that still not explain. Like u skip from video 1 -> video 4 ->video 2

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

    If you have converted this grid to be "top down" in a 3D environment and you need mouse click to be accurate within the grid square >> I placed in a black flat terrain object (at the same elevation level as grid) and do Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); and Physics.Raycast(ray, out hit, 50000.0f); .... hit = the terrain object and then pass hit.point into grid.SetValue(hit.point, value + 5); this way you camera could be a user camera pointing at nearly any orientation but your mouse click is accurate to the grid

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    8 ай бұрын

    Yup exactly in 3D you need a Raycast to find out where it hits the world unitycodemonkey.com/video.php?v=0jTPKz3ga4w

  • @nbixel

    @nbixel

    8 ай бұрын

    I also made some adjustments to the MeshUtils functions to generate a "topdown" mesh rather than a vertical this changed to >> cachedQuaternionEulerArr[i] = Quaternion.Euler(0, -i, 0); then additionally in AddToMeshArrays you will want to subtract the baseSize.y from pos.y to get your vertices "flat"

  • @Soloman274
    @Soloman2744 жыл бұрын

    So is it cool or heat? 😏

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    It's very hot and cool!

  • @damionmccoy9966
    @damionmccoy99662 жыл бұрын

    I love your tutorials I tried to get your MeshUtils.cs I signed up to your website but got no verification email so I can't download anything its been a day now. so I tried recreating it from your videos, by going frame by frame trying to find every line. But for some reason you never show the whole AddToMeshArray function, and since I can't download the sprite you use, or find one like it... I am stuck. Is there anyway your would be willing to post here just the function if not the script. Thank you regardless of what you decide your videos are so inciteful. Also please fix the issue with the verification stuff I would like to be able to see the files and do more tutorials with you.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    The emails sometimes take a while to send but after one day you should definitely have received it, check your spam folder. Or maybe your email provider is blocking the email for some reason, try using gmail or hotmail or any of those usual ones.

  • @damionmccoy9966

    @damionmccoy9966

    2 жыл бұрын

    @@CodeMonkeyUnity I finally figured it out I misspelled Gmail

  • @mahmoueco1200
    @mahmoueco12004 жыл бұрын

    why u use (late update) instead of update

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    4 жыл бұрын

    Because likely other scripts will be modifying the Heatmap during their Update so using LateUpdate will ensure it renders all the changes that happened in that frame.

  • @scios9917
    @scios99172 жыл бұрын

    If your meshArray don't fit to your grid because it's too big, just switch it in 32 bits : "mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;"

  • @Sebastian-oq5qt
    @Sebastian-oq5qt2 жыл бұрын

    Hey, this project is not able to be downloaded from the website so your mesh utilities is inaccesable. That basically makes this tutorial impossible to complete since you rely on outside code not shown in the video.

  • @phildonahue3158

    @phildonahue3158

    2 жыл бұрын

    Until the project files for this video get fixed, you can find meshutils inside the project files of this video kzread.info/dash/bejne/amyXq7iLZK6vj7Q.html

  • @simonaustin5585

    @simonaustin5585

    2 жыл бұрын

    @@phildonahue3158 That project fails to download as well, and the Utilities Downloads doesnt have the MeshUtils class, only the UtilsClass, referenced in the first video... Any way you could post the CreateMeshArrays() function, if you have the script? About half way through the video the arguments are cut off after ... Vector3 BaseSize, Vecto"... Im hoping that is the last reference needed, or that the other methods are more visible... I've been able to get that far! In the mean time, I'll watch the Mesh Video, I guess... lol.

  • @pastuh
    @pastuh3 жыл бұрын

    i need some hints how i can play audio based on object shape and distance.. something like heatmap could work, but how to atchieve this...

  • @kevin41307
    @kevin413072 жыл бұрын

    Hi CodeMonkey, thanks for fantastic tutorial! I have a question in script. When I extent the grid edge to 130*130, the visual of mesh is not work correctly(shrink at x-axis). Does anybody encounter this issue? thanks for help. public class Testing : MonoBehaviour { [SerializeField] private HeatMapVisual heatMapVisual; private Grid grid; private void Start() { grid = new Grid(150, 150, 1f, Vector3.zero); // I only change this line of code. project is download from your website. heatMapVisual.SetGrid(grid); } private void Update() { if (Input.GetMouseButtonDown(0)) { Vector3 position = UtilsClass.GetMouseWorldPosition(); grid.AddValue(position, 100, 2, 25); } } }

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    With that size you've reached the max limit on the mesh size. The maximum number of vertices a mesh can have is 65k, with a grid of 130 by 130 you have 130*130*4 = 67k vertices which will cause that weird behavior. If you need a grid bigger than 120x120 you need to add some logic to manage multiple grids, at least for the visual

  • @kevin41307

    @kevin41307

    2 жыл бұрын

    @@CodeMonkeyUnity Thanks for reply! OK. I will write some handler to handle this limit.

  • @patschin1
    @patschin14 жыл бұрын

    How to make hydraulic from poly bridge????

  • @briangelhorn407
    @briangelhorn4073 жыл бұрын

    very good content but I would like you to explain everything since a lot of things you talk about you never explained in any video and I just don't understand anything

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Can you specify what things you're referring to?

  • @briangelhorn407

    @briangelhorn407

    3 жыл бұрын

    @@CodeMonkeyUnity meshutils

  • @briangelhorn407

    @briangelhorn407

    3 жыл бұрын

    @@CodeMonkeyUnity I know that I can download it to that script but I want to know exactly what I am doing with each method of that script and that does not explain it as for example the addtpmesharrays I do not understand what the basetile is and all that

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    @@briangelhorn407 It handles creating a mesh, I covered it in more detail here kzread.info/dash/bejne/Y2WXm9SQgtLaeps.html

  • @briangelhorn407

    @briangelhorn407

    3 жыл бұрын

    @@CodeMonkeyUnity yeah but you dont explain this in the video... i dont know what is basesize or other values showed in this video (srry my bad english im from argentina)

  • @g5haco
    @g5haco3 жыл бұрын

    Hey code monkey why dont you teach us how to make the building system like battle royale tycoon in unity

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    The Grid System used in this series is exactly what I used for Buildings in Battle Royale Tycoon Watch the Grid Building System video to see it in action kzread.info/dash/bejne/lqmg0dWBgM-eYqQ.html

  • @g5haco

    @g5haco

    3 жыл бұрын

    @@CodeMonkeyUnity thank you!

  • @g5haco

    @g5haco

    3 жыл бұрын

    @@CodeMonkeyUnity Hi code monkey i am looking for the dragging system?

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

    There was code written outside this and the past video.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    Yes, this entire series wasn't planned ahead of time, I just started building the Grid System and continued adding things onto it so it does require some work on your part to see the minor changes between each video.

  • @abdou023

    @abdou023

    2 жыл бұрын

    @@CodeMonkeyUnity Yes, I'm figuring it out as I go. My goal is to implement an X-COM movement system.

  • @Thundorn
    @Thundorn2 жыл бұрын

    Nice video series but I feel like you did more coding "off-camera" then you've added on camera, making it very difficult to follow from the first video to the subsequent videos.

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    2 жыл бұрын

    This series wasn't pre-planned ahead of time so yea some things were made between the videos. However if you watch them all and then look in the final grid system, you should be able to understand all of it unitycodemonkey.com/video.php?v=ezlkGhFBrmg

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

    instead of showing mesh on 12.51 I got NullReferenceException: Object reference not set to an instance of an object HeatMapVisual.UpdateHeatMapVisual () (at Assets/HeatMapVisual.cs:35) HeatMapVisual.SetGrid (Grid grid) (at Assets/HeatMapVisual.cs:19) Testing.Start () (at Assets/Testing.cs:15) which is strange i think i type everything correctly using System.Collections; using System.Collections.Generic; using UnityEngine; public class HeatMapVisual : MonoBehaviour { private Grid grid; private Mesh mesh; private void Awake() { Mesh mesh = new Mesh(); GetComponent().mesh = mesh; } public void SetGrid(Grid grid) { this.grid = grid; UpdateHeatMapVisual(); } private void UpdateHeatMapVisual() { MeshUtils.CreateEmptyMeshArrays(grid.GetWidth() * grid.GetHeight(), out Vector3[] vertices, out Vector2[] uv, out int[] triangles); for (int x= 0; x for(int y = 0; y { int index = x * grid.GetHeight() + y; Vector3 quadSize = new Vector3(1, 1) * grid.GetCellSize(); MeshUtils.AddToMeshArrays(vertices,uv,triangles,index,grid.GetWorldPosition(x,y),0f,quadSize, Vector2.zero, Vector2.zero); } } mesh.vertices = vertices; mesh.uv = uv; mesh.triangles = triangles; } }

  • @HorizoneMeNol

    @HorizoneMeNol

    3 жыл бұрын

    the mesh show up but it's 0 verts 0 tris ...

  • @HorizoneMeNol

    @HorizoneMeNol

    3 жыл бұрын

    please help

  • @HorizoneMeNol

    @HorizoneMeNol

    3 жыл бұрын

    ok so here is the full working code private Grid grid; private Mesh mesh; private bool updateMesh; private void Awake() { mesh = new Mesh(); GetComponent().mesh = mesh; } public void SetGrid(Grid grid) { this.grid = grid; UpdateHeatMapVisual(); grid.OnGridValueChanged += Grid_OnGridValueChanged; } private void Grid_OnGridValueChanged(object sender, Grid.OnGridValueChangedEventArgs e) { //UpdateHeatMapVisual(); updateMesh = true; } private void LateUpdate() { if (updateMesh) { updateMesh = false; UpdateHeatMapVisual(); } } private void UpdateHeatMapVisual() { MeshUtils.CreateEmptyMeshArrays(grid.GetWidth() * grid.GetHeight(), out Vector3[] vertices, out Vector2[] uv, out int[] triangles); for (int x = 0; x for (int y = 0; y int index = x * grid.GetHeight() + y; Vector3 quadSize = new Vector3(1, 1) * grid.GetCellSize(); int gridValue = grid.GetValue(x, y); float gridValueNormalized = (float)gridValue / Grid.HEAT_MAP_MAX_VALUE; Vector2 gridValueUV = new Vector2(gridValueNormalized, 0f); MeshUtils.AddToMeshArrays(vertices, uv, triangles, index, grid.GetWorldPosition(x, y) + quadSize * .5f, 0f, quadSize, gridValueUV, gridValueUV); } } mesh.vertices = vertices; mesh.uv = uv; mesh.triangles = triangles; }

  • @CodeMonkeyUnity

    @CodeMonkeyUnity

    3 жыл бұрын

    Use Debug.Log to find what is null kzread.info/dash/bejne/Z52m2JVpXcW6eto.html

  • @HorizoneMeNol

    @HorizoneMeNol

    3 жыл бұрын

    @@CodeMonkeyUnity thank you so much !!

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

    Create a c# script named MeshUtils and paste the below into it. using System.Collections; using System.Collections.Generic; using UnityEngine; public static class MeshUtils { private static readonly Vector3 Vector3zero = Vector3.zero; private static readonly Vector3 Vector3one = Vector3.one; private static readonly Vector3 Vector3yDown = new Vector3(0,-1); private static Quaternion[] cachedQuaternionEulerArr; private static void CacheQuaternionEuler() { if (cachedQuaternionEulerArr != null) return; cachedQuaternionEulerArr = new Quaternion[360]; for (int i=0; i= 360) rot -= 360; if (cachedQuaternionEulerArr == null) CacheQuaternionEuler(); return cachedQuaternionEulerArr[rot]; } public static Mesh CreateEmptyMesh() { Mesh mesh = new Mesh(); mesh.vertices = new Vector3[0]; mesh.uv = new Vector2[0]; mesh.triangles = new int[0]; return mesh; } public static void CreateEmptyMeshArrays(int quadCount, out Vector3[] vertices, out Vector2[] uvs, out int[] triangles) { vertices = new Vector3[4 * quadCount]; uvs = new Vector2[4 * quadCount]; triangles = new int[6 * quadCount]; } public static Mesh CreateMesh(Vector3 pos, float rot, Vector3 baseSize, Vector2 uv00, Vector2 uv11) { return AddToMesh(null, pos, rot, baseSize, uv00, uv11); } public static Mesh AddToMesh(Mesh mesh, Vector3 pos, float rot, Vector3 baseSize, Vector2 uv00, Vector2 uv11) { if (mesh == null) { mesh = CreateEmptyMesh(); } Vector3[] vertices = new Vector3[4 + mesh.vertices.Length]; Vector2[] uvs = new Vector2[4 + mesh.uv.Length]; int[] triangles = new int[6 + mesh.triangles.Length]; mesh.vertices.CopyTo(vertices, 0); mesh.uv.CopyTo(uvs, 0); mesh.triangles.CopyTo(triangles, 0); int index = vertices.Length / 4 - 1; //Relocate vertices int vIndex = index*4; int vIndex0 = vIndex; int vIndex1 = vIndex+1; int vIndex2 = vIndex+2; int vIndex3 = vIndex+3; baseSize *= .5f; bool skewed = baseSize.x != baseSize.y; if (skewed) { vertices[vIndex0] = pos+GetQuaternionEuler(rot)*new Vector3(-baseSize.x, baseSize.y); vertices[vIndex1] = pos+GetQuaternionEuler(rot)*new Vector3(-baseSize.x, -baseSize.y); vertices[vIndex2] = pos+GetQuaternionEuler(rot)*new Vector3( baseSize.x, -baseSize.y); vertices[vIndex3] = pos+GetQuaternionEuler(rot)*baseSize; } else { vertices[vIndex0] = pos+GetQuaternionEuler(rot-270)*baseSize; vertices[vIndex1] = pos+GetQuaternionEuler(rot-180)*baseSize; vertices[vIndex2] = pos+GetQuaternionEuler(rot- 90)*baseSize; vertices[vIndex3] = pos+GetQuaternionEuler(rot- 0)*baseSize; } //Relocate UVs uvs[vIndex0] = new Vector2(uv00.x, uv11.y); uvs[vIndex1] = new Vector2(uv00.x, uv00.y); uvs[vIndex2] = new Vector2(uv11.x, uv00.y); uvs[vIndex3] = new Vector2(uv11.x, uv11.y); //Create triangles int tIndex = index*6; triangles[tIndex+0] = vIndex0; triangles[tIndex+1] = vIndex3; triangles[tIndex+2] = vIndex1; triangles[tIndex+3] = vIndex1; triangles[tIndex+4] = vIndex3; triangles[tIndex+5] = vIndex2; mesh.vertices = vertices; mesh.triangles = triangles; mesh.uv = uvs; //mesh.bounds = bounds; return mesh; } public static void AddToMeshArrays(Vector3[] vertices, Vector2[] uvs, int[] triangles, int index, Vector3 pos, float rot, Vector3 baseSize, Vector2 uv00, Vector2 uv11) { //Relocate vertices int vIndex = index*4; int vIndex0 = vIndex; int vIndex1 = vIndex+1; int vIndex2 = vIndex+2; int vIndex3 = vIndex+3; baseSize *= .5f; bool skewed = baseSize.x != baseSize.y; if (skewed) { vertices[vIndex0] = pos+GetQuaternionEuler(rot)*new Vector3(-baseSize.x, baseSize.y); vertices[vIndex1] = pos+GetQuaternionEuler(rot)*new Vector3(-baseSize.x, -baseSize.y); vertices[vIndex2] = pos+GetQuaternionEuler(rot)*new Vector3( baseSize.x, -baseSize.y); vertices[vIndex3] = pos+GetQuaternionEuler(rot)*baseSize; } else { vertices[vIndex0] = pos+GetQuaternionEuler(rot-270)*baseSize; vertices[vIndex1] = pos+GetQuaternionEuler(rot-180)*baseSize; vertices[vIndex2] = pos+GetQuaternionEuler(rot- 90)*baseSize; vertices[vIndex3] = pos+GetQuaternionEuler(rot- 0)*baseSize; } //Relocate UVs uvs[vIndex0] = new Vector2(uv00.x, uv11.y); uvs[vIndex1] = new Vector2(uv00.x, uv00.y); uvs[vIndex2] = new Vector2(uv11.x, uv00.y); uvs[vIndex3] = new Vector2(uv11.x, uv11.y); //Create triangles int tIndex = index*6; triangles[tIndex+0] = vIndex0; triangles[tIndex+1] = vIndex3; triangles[tIndex+2] = vIndex1; triangles[tIndex+3] = vIndex1; triangles[tIndex+4] = vIndex3; triangles[tIndex+5] = vIndex2; } }

  • @devchuvak1716

    @devchuvak1716

    Жыл бұрын

    Thank you! It was really useful.