Procedurally Generating A Hexagon Grid in Unity

  Рет қаралды 124,362

Game Dev Guide

Game Dev Guide

Күн бұрын

Пікірлер: 217
@NachitenRemix
@NachitenRemix 2 жыл бұрын
Hexagon is the bestagon.
@yahlunna9799
@yahlunna9799 2 жыл бұрын
In this house we follow the church of Grey
@linda-hernandez-shorts
@linda-hernandez-shorts 2 жыл бұрын
Amen dude
@dark5358
@dark5358 2 жыл бұрын
Porygon > any polygon Otherwise yes
@sunflower4031
@sunflower4031 2 жыл бұрын
All praise our lord hexagon.
@yuriwaki2582
@yuriwaki2582 2 жыл бұрын
scrolled too far to fin this xD
@stonefreak5763
@stonefreak5763 2 жыл бұрын
Hint: If u want to stay in 2D, then the Grid Component in Unity has an option for exactly that.
@AGreatTsunami
@AGreatTsunami 2 жыл бұрын
And one can always extrapolate a tilemap into 3D objects~
@3nertia
@3nertia 2 жыл бұрын
@@AGreatTsunami Wait, what? Would you happen to know of a video or article detailing what you mentioned?
@NominativoUnivoco
@NominativoUnivoco 2 жыл бұрын
However, those hexagons are not accurate
@vinhnghiang1273
@vinhnghiang1273 2 жыл бұрын
what is the game at 0:47 ?
@mcfnord
@mcfnord 2 жыл бұрын
@@NominativoUnivoco Why aren't the Grid Component hexes inaccurate? I have a game that needs hex grid
@bakerfx4968
@bakerfx4968 2 жыл бұрын
My face lit up when I saw you had a new video. It was amazing as always! Thanks dude
@mrlucky974
@mrlucky974 2 жыл бұрын
YES ! Your videos are so great, and this one did not disappoint. Hexagons are the bestagons...
@Sebvantiggele
@Sebvantiggele 2 жыл бұрын
This man deserves more attention, he’s so helpful.
@AliveNotDeadmund
@AliveNotDeadmund Жыл бұрын
For anyone with a null error when you go to render the first hex, make sure you update the return on CreateFace() to return new Face(vertices, triangles, uvs); because he initially writes it as 'return Face()' and then later amends it. Hope that helps!
@Kvn...
@Kvn... Жыл бұрын
Hi, can you check my code, i thing ive done big wrong :8 nothing works
@rickbeniers667
@rickbeniers667 Жыл бұрын
thanks for the comment I had missed him rewritting that part haha
@nj5374
@nj5374 2 жыл бұрын
I'm a massive beginner so most of this went way over my head but this has inspired me to learn to use the mesh renderer by rendering some shapes procedurally - cheers!!
@andrewwilson9052
@andrewwilson9052 2 жыл бұрын
I've just started trying to learn how to code for games and this Channel is just so cool. There's not a lot out there to help learn to make strategy games
@3nertia
@3nertia 2 жыл бұрын
Thank you so much! I searched and searched for this exact thing to no avail!
@simoncodrington
@simoncodrington 2 жыл бұрын
Another great video mate cheers. Can't wait to see what you come up with next!
@akmaludddin9281
@akmaludddin9281 8 ай бұрын
i love how you show the code. i sub immediately! i hope all of you have fun and great days!
@Island54Games
@Island54Games 2 жыл бұрын
Nice stuff. I just started working on hexagons for my own game literally hours before this video came out. One thing I strongly suggest is that you consider using axial or cubic coordinates instead of offset coordinates. While the coordinates aren't quite as intuitive at first, the maths gets *much* simpler. In your coordinate conversions for example, you get rid of all those odd/even conditionals.
@Nanukimo
@Nanukimo 2 жыл бұрын
Is It Possible You Can Show How To Use Axial instead of Offset coordinate system?
@PhaygeWoW
@PhaygeWoW Жыл бұрын
I'm on Unity 2022.3.13f1 and cannot get even the base mesh to render... I have no idea what's going wrong. Has anyone else encountered this?
@dptgames2254
@dptgames2254 Жыл бұрын
At 04:08 my script material just shows none and when I add it as a component it just says none for material and mesh, any one know where I'm going wrong? Are you supposed to add it as a component to something specific?
@phillypustudios
@phillypustudios Жыл бұрын
You probably need to create a new GameObject (named "Hex") and add component > script (HexRenderer) to get to the next point in the video.
@blainewordly9134
@blainewordly9134 2 жыл бұрын
great tutorial can't wait for the next one on hexagonal grids!
@lacata2570
@lacata2570 2 жыл бұрын
"Hexagons are the bestagons" felt like a CGP Grey easter egg
@ekzac
@ekzac Жыл бұрын
You know the tutorial is good when you already know the solution, but it's funny to watch and see the things being built and explained. :)
@Dranzer10HD
@Dranzer10HD 2 жыл бұрын
I've found my new favourite gamedev channel! :D
@cormo9058
@cormo9058 2 жыл бұрын
Great video, I do wish there was some diagrams showing what the different variables in the grid positioning function were doing coz I got very lost there but I'm glad you covered this topic - I've been wondering how to do this for ages
@GameDevGuide
@GameDevGuide 2 жыл бұрын
Check out the blog post linked in the description. It's full of helpful diagrams!
@meowsqueak
@meowsqueak 2 жыл бұрын
@@GameDevGuide The blog post is great, however I feel your videos would be improved by a few diagrams, especially when explaining more algorithmic parts of the code, like looping around the faces. As it is, the videos are a little too "just write this and it'll work" rather than "this is how it works", and I think your obvious ability to communicate would be enhanced into one of teaching by this slight change in approach.
@j.j.maverick9252
@j.j.maverick9252 2 жыл бұрын
Nice video, the mesh building is very clean. Surprised you didn’t use the axial/cube representation from redblob though, it simplifies everything related to selection which is a huge part of many hex games
@GameDevGuide
@GameDevGuide 2 жыл бұрын
Watchout for part 2 😉
@j.j.maverick9252
@j.j.maverick9252 2 жыл бұрын
@@GameDevGuide subscribed and notified!
@Nanukimo
@Nanukimo 2 жыл бұрын
@@GameDevGuide Whens Part 2??
@vinhnghiang1273
@vinhnghiang1273 2 жыл бұрын
what is the game at 0:47 ?
@WigglesworthJr
@WigglesworthJr 2 жыл бұрын
Great video, I'm collecting tutorials like this to learn and also have a nice reference when building something similar. Appreciate the time you took to help the community. For those with an issue setting the material, I think there was a method setup in the HexRenderer that wasn't shown but you can use something like this if you need it. public void SetMaterial(Material newMaterial) { m_meshRenderer.material = newMaterial; }
@HaoaHaNa
@HaoaHaNa Жыл бұрын
I'm having trouble setting up the innersize, outersize, and height. Can you help?
@WildPork
@WildPork Жыл бұрын
@@HaoaHaNa [SerializeField] private Material material; [SerializeField] private float innerSize; [SerializeField] private float height; [SerializeField] private float outersize; then set them in the inspector
@DmytroMomotov
@DmytroMomotov 2 жыл бұрын
Good tutorial, it would be helpful to have visual representation of what code is doing side by side with current piece of code, otherwise it becomes a bit confusing
@Kwevino
@Kwevino Жыл бұрын
How do you use the script? What do you do after you've written it?
@Rhanati
@Rhanati Жыл бұрын
This is an awesome video, thank you for the explanation!
@jackpaice
@jackpaice Жыл бұрын
Please make your code available on a repo so we don't have to spend 1h trying to figure out where we went wrong by copying manually.
@SkellingtonWheel
@SkellingtonWheel 2 жыл бұрын
So from what I see, this creates multiple hexagon meshes and then aligns them side-by-side so that neighbouring vertices overlap. Is there a way to merge the overlapping vertices in a way that retains the triangle faces, so that something like a perlin noise algorithm could generate some cool terrain?
@boiimcfacto2364
@boiimcfacto2364 2 жыл бұрын
I was one of the first subscribers of Sebastian Lague - and I'm so glad I found another eloquent, entertaining Unity content creator in his early days. Trust me man, you're gonna make it big. Fantastic video.
@weks
@weks 2 жыл бұрын
Amazing stuff as always! Thanks for the content!
2 жыл бұрын
Great video, as usual :-) Calculating Math.sqrt(3) is expensive, and because you are doing that several times, maybe you could create a constant with that value instead.
@td19xyz
@td19xyz 2 жыл бұрын
Microsoft's CLR (the C# virtual machine) is able to optimize away the call to sqrt(3). It might not bother in debug builds though. That being said, you use sqrt(3) often enough `SQRT_3` might be more legible than `Math.sqrt(3)`
@Neph0
@Neph0 2 жыл бұрын
Allocating memory for the list at every tick probably has a much bigger performance impact here. But honestly is it such a big deal for a prototype like this? Nobody cares.
@Chris-lw5po
@Chris-lw5po 2 жыл бұрын
@@Neph0 maybe newer game devs that don’t know the best practices and or why this wouldn’t scale well into a big project? I definitely am interested in hearing points like this…
@vinhnghiang1273
@vinhnghiang1273 2 жыл бұрын
what is the game at 0:47 ?
@brainwavestobinary
@brainwavestobinary 2 жыл бұрын
@@vinhnghiang1273 That game is called, "Before we Leave".
@Ferenc-Racz
@Ferenc-Racz 2 жыл бұрын
Thank you for your knowledge sharing. Subscribed and liked offcorse. :)
@rutchjohnson
@rutchjohnson 2 жыл бұрын
For those getting an error when first rendering your hex it might be related to the OnValidate method. I had to check for not null on m_mesh. Example: if(Application.isPlaying && m_mesh != null)
@TeveshKP
@TeveshKP 2 жыл бұрын
I typed up the code seen in the video but Unity is giving me a bunch of errors. Is there something that I should be doing that's not being covered?
@rutchjohnson
@rutchjohnson 2 жыл бұрын
@@TeveshKP I've only completed generating the hex. The code in the video works. I haven't started coding the grid yet.
@TeveshKP
@TeveshKP 2 жыл бұрын
@@rutchjohnson Huh, then I wonder what I'm doing wrong. Researching, it seems that this may be a custom editor and I missed that fact.
@rutchjohnson
@rutchjohnson 2 жыл бұрын
@@TeveshKP I’m not using a custom editor.
@dislexei
@dislexei Жыл бұрын
Thank you! Been debugging that one for the last couple of hours :)
@simplegamedev4342
@simplegamedev4342 2 жыл бұрын
Great video, can't wait for the next one :)
@BurzowySzczurek
@BurzowySzczurek 2 жыл бұрын
0:01 What kraków does there? I live in it. (Actually on a border)
@mementomori7160
@mementomori7160 2 жыл бұрын
0:22 And in my, hexagons are... bestagons Edit 1: 0:51 YES my brother! Also I've already worked on it for a while, there is a simple way to make hexagon based coordinate system, also allows for making layers of hexagon tiled planes, I guess you'll show it on one of other methods soon
@Lukazkool
@Lukazkool 2 жыл бұрын
When I am setting up the DrawFaces() Method, it is saying that innerSize, outerSize, height, and height don't exist in the current context. I already tried swapping them with innerRad, outerRad, heightA, and heightB, but it still didn't work. Does anyone know how to fix this?
@androsynth976
@androsynth976 2 жыл бұрын
6:24
@iurieysi9103
@iurieysi9103 2 жыл бұрын
5:38 if you want to convert to radians Mathf has a Deg2Rad constant which is equal to Mathf.PI/180f
@j.j.maverick9252
@j.j.maverick9252 2 жыл бұрын
I thought the same thing but realised it’s always good to know the derivation of those constants too… some game engines don’t have them, and not all programmers use them.
@iurieysi9103
@iurieysi9103 2 жыл бұрын
@@j.j.maverick9252 I agree
@Galaxhjalt
@Galaxhjalt 8 ай бұрын
i am getting a CS0103 error for height, innersize and outersize for the Drawfaces method at the end. i cant see any misstakes that i have made in my code, any help?
@wannachill4982
@wannachill4982 2 жыл бұрын
I got a problem. For some reason my OnValidate is not working properly. I can change innerSize or outerSize but while changing it leaves like trace of tiles and they are not removing ( Also in LayoutGrid() i cant write tile.SetParent(transform, true); because .transform is missing - so i think may be it can cause my problem?
@jamesmamaliga4824
@jamesmamaliga4824 2 жыл бұрын
I'm having the same issue, did you manage to fix it?
@wannachill4982
@wannachill4982 2 жыл бұрын
@@jamesmamaliga4824 No
@MrYTThor
@MrYTThor 2 жыл бұрын
Did you try it with a newer version? Try changing it to: tile.transform.SetParent(transform, true); Maybe it helps.
@AliveNotDeadmund
@AliveNotDeadmund Жыл бұрын
@@MrYTThor Thank you!
@Rhanati
@Rhanati Жыл бұрын
The created tiles are not deleted. To achieve this, you can add a ClearGrid() to the onValidate(): Add a List of the created tiles: private List tiles = new List(); Add all created tiles in the LayoutGrid to this List: tiles.Add(tile); Create a ClearGrid function: private void ClearGrid() { foreach (GameObject tile in tiles) { Destroy(tile); } tiles.Clear(); } Call the ClearGrid(); before LayoutGrid(); in your OnValidate().
@TimurKOI
@TimurKOI 2 жыл бұрын
Thank you very much for this video! For me it is too complicated at first look but again thank you for detailed explanation without useless waste of time! HUGE like and subscribe!
@flashpaperdotru
@flashpaperdotru 2 жыл бұрын
This is a very cool video and it will help me a lot in my engine. Thanks!
@DevOverdrive
@DevOverdrive 2 жыл бұрын
I love your videos. Please keep up the good work! Can you make a video on setting up a car traffic system or a raycast detection system.
@jasher1608
@jasher1608 2 жыл бұрын
Hello, does anyone know how I could outline the grid so that I could see the borders of the individual hexes? Thank you
@Lastered
@Lastered 2 жыл бұрын
Does anyone know what game that is at 0:23 ? I've been looking to play that game! Edit: for anyone wondering the game is called Opus Magnum by Zachtronics
@7yearsago440
@7yearsago440 2 жыл бұрын
Thanks
@radicaldaddy8149
@radicaldaddy8149 Жыл бұрын
Hi, I finished writing the code but how do i make it so it would automaically run after I start my program?
@Mat-r5n
@Mat-r5n 6 ай бұрын
My console is returning the error code: Mesh.uv is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array. UnityEngine.Mesh:set_uv (UnityEngine.Vector2[]) But it seems to be generating the hexagon correctly. Still, it's a bit annoying... how do I fix this? It's also returning a: NullReferenceException: Object reference not set to an instance of an object At first, but it disappears if I remove the OnValidate() function. Edit: I ran into another problem... Whenever I try to adjust it on the HexGridLayout script, it always instantiate new cells instead of adjusting the existing cells.
@jeshuanavarrogarcia
@jeshuanavarrogarcia 2 жыл бұрын
Thanks, and waiting for the next video for thepathfinding and fog of war!
@BlueHat1
@BlueHat1 2 жыл бұрын
Thank yiu for the tutorial, but it would be so much better if you explained what you were doing more and helped us visualize it. I was left a bit confused.
@TemProduction
@TemProduction 2 жыл бұрын
From which games did you use the clips in this video? Also can you draw hexagon shaped grids, so all the hexagon tiles in a hexagon shape Thank You
@lesliejohnrichardson
@lesliejohnrichardson 2 жыл бұрын
Damn this was definitely an amazing video that inspired me to choose hexagons as the general theme for my game :D
@falricthesleeping9717
@falricthesleeping9717 2 жыл бұрын
This Was a great video, albeit, I found myself not quite understanding what's going on where you used sin and cosin, but perhaps that's my job to actually study the link that you provided I was Looking for procedural generation and this video was helpful to what things I must do, but I will probably not use a hex grid in the foreseeable future awesome video thanks mate
@Tin_Protopixel
@Tin_Protopixel 2 жыл бұрын
When I create m_mesh=new Mesh() later in the CombineFaces() I get NullReferenceException: Object reference not set to an instance of an object . After debugging tunes out that ,_mesh is still null. Been looking at this for a while now and cant figure out why.
@SkellingtonWheel
@SkellingtonWheel 2 жыл бұрын
I had the same issue, another commenter wrote the solution. In "OnValidate()" add "&& mesh != null" in the if statement, after Application.isPlaying
@Tin_Protopixel
@Tin_Protopixel 2 жыл бұрын
@@SkellingtonWheel cant confirm myself(not using the project anymore), but if anyone reading and trying this, please confirm if true
@leventeberes3829
@leventeberes3829 2 жыл бұрын
@@Tin_Protopixel I had the same problem, and using the check made it go away.
@mobilelast1715
@mobilelast1715 2 жыл бұрын
Great explanation. That Red Blob's hex-site you mentioned is indeed an excellent resource. Hex grid is actually a special case of the Voronoi diagram. Another curious pattern that all programmers should be aware of.
@stephenkirby6788
@stephenkirby6788 2 жыл бұрын
I'm not using anything like this right now in my projects, but I watched it anyways. Very informative and great production value. Next level!
@vinhnghiang1273
@vinhnghiang1273 2 жыл бұрын
What is the name of the game at 0:47???
@tristanbluhm
@tristanbluhm 2 жыл бұрын
What is the name of the game at 0:23, I can never remember the name and I've been wanting to play it
@lucasd.3369
@lucasd.3369 Жыл бұрын
OPUS MAGNUM
@gorgeousorc
@gorgeousorc 9 ай бұрын
Great tutorial, straightforward! Thanks. One thing I noticed was forgetting to disable OnEnable drawing of mesh after implementing the HexGridLayout. Which was resulting in the grid creating 2 versions of itself. A sneaky catch that was leading to performance issues. I have a question, maybe you have addressed already, but how would you approach giving each hex a collider to be raycasted/interacted with? I tried creating a MeshCollider based on the sharedMesh of the mesh we create but to no avail.
@Raccoon0710
@Raccoon0710 2 жыл бұрын
I have an issue, hexagon is not rendered if it’s center is outside of my camera view 😢
@Kashev101
@Kashev101 Жыл бұрын
the hexRenderer.SetMaterial(material) is giving an error in unity saying the HexRenderer script does not contain a definition for SetMaterial, Anybody know the fix around that?
@meowsqueak
@meowsqueak 2 жыл бұрын
Great video, looking forward to the next one. BTW one should NOT call DrawMesh() in OnValidate() because this creates a horrible race condition, as OnValidate() can be called before Awake() resulting in numerous null dereference attempts. Instead, OnValidate() can set a flag that Update() checks before calling DrawMesh(), or Awake() can set a flag that OnValidate() checks before calling DrawMesh(). I favour the former because the Unity docs for OnValidate() actually say that this function should not be used to create objects. It's only meant for validating existing data.
@OBrownie_
@OBrownie_ 2 жыл бұрын
Bruh, i'm getting this error, and i don't know how to fix it (i'm more than a noob in programming), can you write here the code correction please?
@meowsqueak
@meowsqueak 2 жыл бұрын
@@OBrownie_ sorry I don't have the code any more - but from memory, instead of calling DrawMesh() in OnValidate(), just set a bool flag to true, and then in Update(), if the flag is true, then call DrawMesh(). This ensures that the mesh is only created in the Update phase, and never before Awake (which can happen sometimes because OnValidate() can be called before Awake() is). Hope this helps.
@bachhoang9004
@bachhoang9004 2 жыл бұрын
awesome as always
@xanmichaels
@xanmichaels 2 жыл бұрын
I can't seem to show my hex in the scene . The only way I can see my hex is by hitting the play button. Is there is a download link for the code maybe I miss something
@xanmichaels
@xanmichaels 2 жыл бұрын
i have the content downloaded from patron it just made it worst. i just want this thing to show up in scene lol.
@magq1246
@magq1246 Жыл бұрын
great vid, great explanations, love it +1 follower
@TeveshKP
@TeveshKP 2 жыл бұрын
I copied your code on screen exactly and it didn't output anything but errors. Is it because you switched terms without correcting the edit? For example, the private void DrawFaces had very similar code to the private void DrawMesh.
@junjiepeng
@junjiepeng 2 жыл бұрын
I have the same problem that there is no output but two errors.I cant find any difference between video and my codes.
@AliveNotDeadmund
@AliveNotDeadmund Жыл бұрын
Glad I'm not the only one. I've tried the fixes put forward by other commenters and none of them work. Would be nice to see the script in full at the end of writing. :/
@Liamneedham29
@Liamneedham29 Жыл бұрын
@@junjiepeng Two Errors. Perhaps we have the same ones. HexRenderer does not contain a definition for SetMaterial, and same thing for GameObject ... Set Parent. If I find solution, I will post it here. Just starting to get back into code after years and years haitus, and I was never that proficient, so I expect to run into a lot of errors. Copying the code from the video is really difficult, it changes slide to slide as he fixes errors between shots. This is not to mention that I have no doubt mistyped something, it makes following the tutorials and actually getting something working to play around with very difficult, but I just can't learn on theory only. Would be good to see the final clips of the script.
@Liamneedham29
@Liamneedham29 Жыл бұрын
Okay I've found the problem. At some point, UnityEngine stopped allowing a bunch of the components of GameObject to be referenced. Don't know how long ago this change happened, can't find any documentation on the update itself. SetParent is now part of Transform, so the correct line here is tile.transform.SetParent(transform, true); The SetMaterial on the other hand doesn't exist at all, only as part of a CanvasRenderer. This line just appears to be completely wrong. In this part of the code we are creating GameObjects of type HexRenderer, referencing the variables at the top of the HexRenderer script, and assigning to them the variables in this script. So the material should be the same pattern as all the other variables we used. hexRenderer.material = material; I think, I could be wrong, but the errors go away with these changes. Hope this helps. Annoying that the video is either already out of date after a year, or just riddled with mistakes. Clearly a lot of work has been put into making the video, but its a big barrier to learning that videos need to be basically perfect and released a day ago to be even functional. Even after fixing these errors, I still have a lot of tweaking to do to even get Hexagons appearing, which I see is a problem many others were having.
@divac7777
@divac7777 Жыл бұрын
@@Liamneedham29 Got those same 2 errors
@KaryoSentiko
@KaryoSentiko 5 ай бұрын
I am certain I have followed this to the letter, but I am getting a null reference exception error. Anybody have any idea why?
@RG-ef8vm
@RG-ef8vm Жыл бұрын
Nice video, I was able to follow along just fine, and complete the project. Question: When I create the grid initially, it takes ~250ms. However, when it is recreated using OnValidate, it takes over 5 seconds. I then tested by just calling Invoke("LayoutGrid", 10f) in Start(), and changing the inner size before the 10s expired, and it again took only ~250ms. Why does it take ~20x longer to execute when called in OnValidate?
@Tasarran
@Tasarran 2 жыл бұрын
Instant like for "Hexagons are the bestagons!"
@RandomProduct
@RandomProduct 2 жыл бұрын
0:28 what game is this? It looks adorable.
@HexShaped
@HexShaped 2 жыл бұрын
Before We Leave
@HereBeCush
@HereBeCush 2 жыл бұрын
Great tutorial! Absolutely loved it 👏🏻 I found in my case that the hexagons were disappearing when they got near the edge of the screen. I fixed this by setting the size of mesh.bounds in the DrawMesh function (center being Vector3.zero and the size being a slightly different Vector3 depending on whether the hex is flat-topped or not) The full code I added: Vector3 boundSize = new Vector3( outerSize, height, outerSize ); if( isFlatTopped ){ boundSize.x *= 2f; boundSize.z *= 1.75f; }else{ boundSize.x *= 1.75f; boundSize.z *= 2f; } mesh.bounds = new Bounds( Vector3.zero, boundSize );
@vinhnghiang1273
@vinhnghiang1273 2 жыл бұрын
what is the game at 0:47 ?
@GregX999
@GregX999 Жыл бұрын
You can also just use "mesh.RecalculateBounds()" right after "mesh.RecalculateNormals()" in the "CombineFaces()" method.
@HereBeCush
@HereBeCush Жыл бұрын
@@GregX999 Awesome, didn't know this - thanks!
@rutchjohnson
@rutchjohnson 2 жыл бұрын
Yessss! I love this tutorial!!
@r.rodriguez4991
@r.rodriguez4991 2 жыл бұрын
What is the game at 0:08? The art style is awesome.
@pifopifo1000
@pifopifo1000 2 жыл бұрын
As some once famous youtuber said, Hexagons are the bestagons.
@musey86
@musey86 Жыл бұрын
Think this needs an update, tried doing this is Unity 2021.3.19f1 and while I can make a grid, I get a tonne of warnings thrown out about "Send message cannot be called during Awake, CheckConsistency, or OnValidate" - If I comment out the 'On validate' sections the grid won't generate, but if I leave them in, when I update the grid size it leaves the hexes that should disappear causing a mess of gameobjects. Also, even though the code is carbon-copy of what's show, when I invert into the 'IsFlatTopped', the hexes will move but they're not aligned properly.
@GrigTea
@GrigTea Жыл бұрын
I have the same problem. Were you able to fix it?
@bradleysmith9924
@bradleysmith9924 2 жыл бұрын
Any advice for presenting/wrapping the grid around a sphere?
@Raven-su7bw
@Raven-su7bw 2 жыл бұрын
0:27 what game is it?
@DaneC020
@DaneC020 2 жыл бұрын
Looking forward to the pathfinding and fog of war episodes!
@Mouton_redstone
@Mouton_redstone 2 жыл бұрын
I am very excited for the pathfinding
@ObsessiveGames
@ObsessiveGames 2 жыл бұрын
Great tutorial thanks
@D-Dev
@D-Dev 2 жыл бұрын
It’s looks really cool but how about with performance in this this solution. Can we just save somehow our procedurally generated hex as prefab and not calculated it each time when we want to display it?
@thipoktham5164
@thipoktham5164 2 жыл бұрын
Hello, this video is awesome!
@rohan_mayya
@rohan_mayya 2 жыл бұрын
This is still somewhat incomplete. - What about retrieving a vertex or edge on demand? - What about hex representation? Cube/axial/offset? What would you suggest is the easiest way to retrieve a hex (say, by a map) given your implementation?
@rohan_mayya
@rohan_mayya 2 жыл бұрын
Good video by the way, just feel like it can be taken a notch above with a part 2
@KICKinYaFACE
@KICKinYaFACE 2 жыл бұрын
How are you managing the children of the HexLayout GameObject? This part isn't shown in the video ... the way it is presented is calling LayoutGrid() inside OnValidate() and this causes a re-creation of the entire HexGrid on top of the existing one - on every single tick of OnValidate. As workaround, I added a short cleanup before calling LayoutGrid to wipe away all children of the HexGrid before creating a new one, but this doesn't seem to be the most efficient way of doing things.
@RickoDeSea
@RickoDeSea 2 жыл бұрын
What are the names of those games u showed as examples ?
@7yearsago440
@7yearsago440 2 жыл бұрын
What is this game 0:24?
@naramoro
@naramoro 2 жыл бұрын
What's the game at 0:08-0:10? Looks awesome
@UHILLE
@UHILLE 2 жыл бұрын
ı try to write same code to develop my skills but in the point of we create "m_faces.Add(CreateFace(innerSize,outerSize,height/2f,height/2f,point));" this code ı have an error which is "the name innerSize does not exist in the current context" but we use that name to refer to "private Face CreateFace(float innerRad, float outerRad, float heightA, float heightB, int point, bool reverse = false)" but it doesnt work can anyone help me about this error
@UHILLE
@UHILLE 2 жыл бұрын
o after that you showed the creation of public float innerSize codes okey ı am fine now :D but how can you do that unity drawing things ı couldnt see that
@MatthiasTTV
@MatthiasTTV Жыл бұрын
You shouldn't just arrange the hexagons next to each other; you should check if there is a neighboring hex and not redraw those edges. You'll save a huge number of tris and verts.
@lonkerr5588
@lonkerr5588 2 жыл бұрын
Thank you so much!
@DS-rd8ud
@DS-rd8ud 2 жыл бұрын
Cool video. The background music is a bit distracting, though. Keep it up!
@barsmehmetbalc6339
@barsmehmetbalc6339 Жыл бұрын
why do you add offset to triangles?
@TuberTugger
@TuberTugger Жыл бұрын
So that the triangles form a hexegon
@alexandrecolautoneto7374
@alexandrecolautoneto7374 11 ай бұрын
Tried to make a square board, when I looked all my squares got 6 sides, Hexagons are truly the bestagon.
@GodGuy8
@GodGuy8 Жыл бұрын
you need to paste the code in the description or github bc for me a lot of stuff is underlined in red and im not sure why. its cool that this stuff is possible but seems a little out of reach for me rn without more help. thanks though
@TheKnightArgent
@TheKnightArgent 2 жыл бұрын
What game is that at 0:28 ?
@HexShaped
@HexShaped 2 жыл бұрын
Before We Leave
@immortalsun
@immortalsun 2 ай бұрын
Hexagons are the bestagons! :)
@mauroabidalcarrer4083
@mauroabidalcarrer4083 2 жыл бұрын
10:25 whats the name of the game?
@r.gtz.4521
@r.gtz.4521 2 жыл бұрын
I came here to ask this as well!
@bartoszwittner8938
@bartoszwittner8938 2 жыл бұрын
That's "As Far As The Eye"
@ggshout3019
@ggshout3019 Жыл бұрын
Made it all works except the last part with the grid, for that I slapped a prompt in ChatGPT and works now. It was confusing at times, but it's doable.
@Developesque
@Developesque 2 жыл бұрын
Thanks for this guide, it helped me out a lot. Anyone have tips for laying this grid on top of a plane programmatically? I am eventually trying to project the grid overtop of terrain. Step at a time.
@ragerungames
@ragerungames 2 жыл бұрын
Awesome!!
@LimitedBits
@LimitedBits Жыл бұрын
For anyone wondering why it's not working on newer versions of Unity you need to comment out the OnValidate method and replace the OnEnable method with Update. This will make sure it draws every frame like in the video, just won't work in the editor.
@twentyhands
@twentyhands 2 жыл бұрын
Me, just starting to learn game dev: "mhm, I know some of these words."
@warfrogsstudio
@warfrogsstudio Жыл бұрын
Mmmh.. It does not work. I have copied everything and nothing is showing anywhere. I have checked twice, all the code is identical Edit: I don't have any error or anything. Did some debug.log and all is properly set.. very odd..
@TuberTugger
@TuberTugger Жыл бұрын
It doesn't render in editor mode. It's generated at run time. Hit the play button
@warfrogsstudio
@warfrogsstudio 8 ай бұрын
@@TuberTugger Does not work either, no error, but nothing shown. I am using Unity 2021.3.33f1
@warfrogsstudio
@warfrogsstudio 8 ай бұрын
Alright, turns out, OnValidate() should be calling DrawMesh() instead of what he wrote, otherwise, the mesh is NEVER refreshed... PROBLEM SOLVED
11 Things You (Probably) Didn't Know You Could Do In Unity
13:49
Game Dev Guide
Рет қаралды 157 М.
Generating A Hex Map With Fog Of War in Unity
20:27
Game Dev Guide
Рет қаралды 55 М.
Caleb Pressley Shows TSA How It’s Done
0:28
Barstool Sports
Рет қаралды 60 МЛН
Hexagons are the Bestagons
9:27
CGP Grey
Рет қаралды 15 МЛН
Unity Tilemaps - Hex, rectangle, isometric + rule tiles
18:38
I Created My Own Custom 3D Graphics Engine
26:29
Inkbox
Рет қаралды 124 М.
D&D HexCrawls! How To Do Exploration RIGHT!
9:50
Dungeon Masterpiece
Рет қаралды 284 М.
Unlocking The Power Of Unity's Scriptable Render Pipeline
21:05
Game Dev Guide
Рет қаралды 229 М.
Pathfinding - Understanding A* (A star)
12:52
Tarodev
Рет қаралды 141 М.
Why The Longing Takes Four Hundred Days to Play
20:45
Adam Millard - The Architect of Games
Рет қаралды 7 МЛН
every step to actually make your dream game (then sell it)
24:27
How To Build Roads Procedurally In Unity with the Splines Package
17:51