UE4 Tutorial: Hex Grid

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ก.ย. 2024
  • How to make a simple and flexible hex-based tile grid in UE4. Topics covered: Asset handling, constructions scripts, blueprint scripting.
    LINKS:
    Assets Download - bit.ly/2RDMrc5
    SUPPORT:
    PayPal - www.paypal.me/...
    Gumroad - gumroad.com/ja...
    Patreon - / underscoremedia
    CONTACT:
    Discord - / discord
    Twitch - / bevd0g
    ArtStation - www.artstation...
    E-Mail - underscore@gmx.com

ความคิดเห็น • 74

  • @Derogue23
    @Derogue23 ปีที่แล้ว +6

    Thank you. Everyone else made this so complicated and you simplified it completely.

  • @txpae
    @txpae 2 ปีที่แล้ว

    This really help me, thanks man!!

  • @arknet4973
    @arknet4973 4 ปีที่แล้ว

    Modify your code in order to make hexagons moveble. Ger actor location. And before select vector make + according to the axis

    • @ReprobateMind
      @ReprobateMind 4 ปีที่แล้ว

      I'm retrying my hand at game design and I'm struggling to understand your comment, I need to make each one of these hexagons I have their own object, as I need to spawn different meshs at different locations randomly and have them have their own properties. I was more on the 3d and animation side in college so I have limited understanding of blueprints and my memory is hazy, is this the way I need to do it? Or can you point me to a different approach? Cheers!

    • @arknet4973
      @arknet4973 4 ปีที่แล้ว

      @@ReprobateMind Ok. If you want that the hexagons folowed by the actor you should take the actor location in hexgon place counting.

    • @arknet4973
      @arknet4973 4 ปีที่แล้ว

      @@ReprobateMind I'm retrying my hand at game design - can help with this.

  • @Extrone
    @Extrone 4 ปีที่แล้ว +13

    There's actually a Macro in UE4 called "2d Grid Execution Macro" to generate 2d grids, but I don't think it works for Hex grids. Thanks for the tutorial 🙂

  • @jamesgellert1263
    @jamesgellert1263 4 ปีที่แล้ว +5

    Thank you for taking the time and trouble making these beautiful tutorials I can see most of the people in the comment are very demanding not all of them but most of them didnt say thank you or anything so "thank you so much for making these tutorials keep up the good work"

  • @DanPos
    @DanPos 3 ปีที่แล้ว +1

    This works in theory, but in practice it isn't performant at all unfortunately - when the camera sees a lot of the tiles at once it really slows down - any idea on how to make this more performant?

    • @underscore00
      @underscore00  3 ปีที่แล้ว +1

      Yes, the reason for this is to simplify the code to make it more readable and easy to understand. For increased performance, you could use instanced static meshes and instead of 'add static mesh' youd use 'add mesh instance' (named that or something similar, i cant remember off the top of my head). Instanced meshes are very high performing so if you need a grid of thousands of tiles, thats a good way to do it.
      Another way to go is to move the code to Begin Play and spawn blueprint actors with a tile in it instead of simply a static mesh. This opens you up to all kinds of added functionality, including culling the meshes at distance to lessen the impact on your hardware.
      I hope that puts you on the right track! This is one of those videos I'd really like to expand on, so thanks so much for the question :)

    • @DanPos
      @DanPos 3 ปีที่แล้ว

      @@underscore00 Amazing, thanks for the reply. I will take a look into the other routes mentioned :) Ideally, blueprint actors would be best for my case - so will do a bit more research in that area

  • @NeverEverFaceTheDark
    @NeverEverFaceTheDark 3 ปีที่แล้ว +3

    If I wanted to, say, overlay this hexgrid (invisible) over my landscape, would i just have to make the hexes super tall (to account for height differences)? Is there a better way like molding a grid to the landscape? (thank you for this video by the way! very cool.)

    • @Shrooblord
      @Shrooblord 2 ปีที่แล้ว

      Probably better to project a Material down onto the landscape, possibly even as a decal.

  • @TheCreakyChair
    @TheCreakyChair หลายเดือนก่อน

    I know this is old and now UE5, but how easy is it to add a tree symbol or lake symbol to the hexes?
    Thank you also.

  • @MagicisHerba
    @MagicisHerba 4 ปีที่แล้ว +3

    Love these tutorials man! Ever think about doing a grapple swing like A Hat in Time? ;)

  • @tgsnicholas8817
    @tgsnicholas8817 4 ปีที่แล้ว +8

    could this work with cubes too? Edit: I tried, it works perfectly with any shape, ty!

    • @elegmant
      @elegmant 4 ปีที่แล้ว

      Thx for the answer!

  • @shadesmadness4399
    @shadesmadness4399 3 ปีที่แล้ว +1

    What if we need to scale the mesh up? Just re-import a bigger version of the hex?

  • @CAgram123
    @CAgram123 2 ปีที่แล้ว

    Outdated. The hex grid begame one of Blender's extra objects in 2021. It would be more easier to import it and avoid all the math.

  • @sunnymon1436
    @sunnymon1436 8 หลายเดือนก่อน

    Hex tiles are very annoying to get evenly spaced.

  • @Maxparata
    @Maxparata 4 ปีที่แล้ว +2

    I searched that for 2 years! I didn't know the name of the grid so I was struggling! XD Now I see how easy it is... It's a shame... Thank you very much for that tutorial.

  • @droppydroop6617
    @droppydroop6617 4 ปีที่แล้ว +2

    FPS FPS FPS series plzzzzzz

  • @hcm7653
    @hcm7653 3 ปีที่แล้ว +1

    How can ı get hex shape???
    Can you help me?
    Discord : CAN#6706

  • @CryptoNewsTV
    @CryptoNewsTV 2 ปีที่แล้ว

    How can you make this into a sphere? A hexagon sphere from a single tile would be great for games. Any help?

  • @Video-yi1lv
    @Video-yi1lv 4 ปีที่แล้ว +1

    Awesome video! Can you make tutorial how to make shell ejecting gun please

  • @stephenlastimosa4551
    @stephenlastimosa4551 4 ปีที่แล้ว +1

    When i drag and drop the HexGrid_BP it still only shows 1 tile

  • @issamaf80
    @issamaf80 4 ปีที่แล้ว +1

    awesome tutorial if you do request can you make first person camera that is similar to resident evil 7 with the knife mechanic , thanks btw i sub to you

  • @drewmalesky9869
    @drewmalesky9869 4 ปีที่แล้ว +1

    Hi UE newbie here, Great Tutorial. I got the hex grid working alright, but is there a way to make the grid more ....Catan like?....a hexagon made out of smaller hexagons?

    • @Shrooblord
      @Shrooblord 2 ปีที่แล้ว

      You'll probably want to generate the tiles in rings rather than in 'square-like' coordinates.

  • @BritishAdam
    @BritishAdam 4 ปีที่แล้ว +1

    ace tutorial, despite all being created in one go, and appear on the right hand side list of items (actors?), does each tile act individual and be made to be clicked on individually by the user instead of one or all?

    • @Drunkenvalley
      @Drunkenvalley 4 ปีที่แล้ว

      In this the tiles would be all part of a single actor. If you want to create individual actors, you'd want/have to create actors instead of meshes, and also possibly want to place it in the level's blueprint instead.

  • @nexistudios2466
    @nexistudios2466 4 ปีที่แล้ว +2

    Love your tuts bro

  • @fifi8284
    @fifi8284 ปีที่แล้ว

    there is a issue with this code where it keeps all previous tiles every time it updates and the fix is to add a CLEAR array before the ADD array at the end. dont forget to cunnect the HexTiles variable to the CLEAR array. this should help with lag

  • @RiseOfDeath
    @RiseOfDeath 4 ปีที่แล้ว

    Just a noob question - why hexmap consist of meshes? Maybe better to make Actor - HexTile with it's mesh and internal parameters and behaviour (for example with different materials (terrain type), different height and etc controled by tile) and make HexTileMap from this HexTile actors? (And there is question, I didn't find how to do Actor factory inside other actor?)

  • @II-er7gj
    @II-er7gj 2 ปีที่แล้ว

    Can you do grid material tutorial for LANDSCAPES please?

  • @murnoth
    @murnoth ปีที่แล้ว

    Thanks this was very helpful! Do you have a video about setting the height mapped from Noise?

  • @antoniopepe
    @antoniopepe 3 ปีที่แล้ว

    hi Master. im searching a way to blend different level track of the same group of object.
    I'll explain. i exported 32 neon tube from c4D . and 4 different loop baked rotation animation.
    now i want to blend this 4 different track. there is a way to blend as ì if it were a skeleton. because there is no interpolation from track to track. thx in advance.!

  • @NeverEverFaceTheDark
    @NeverEverFaceTheDark 3 ปีที่แล้ว

    The final question I have about this is: how do i make spacing relative to the size....hmmmm

  • @thebadluckraven8217
    @thebadluckraven8217 ปีที่แล้ว

    If I wanted to store the location of each instance in an array how would I go about that? I want to use the array of locations for reference to place other objects

  • @drewhalcro6082
    @drewhalcro6082 2 ปีที่แล้ว

    How did you make the hexagon in the first place?

  • @gadji2011
    @gadji2011 4 ปีที่แล้ว

    very cool!!
    Please do more videos on the same topic. For example moving on a HEX grid
    (очень круто!!
    Сделай пожалуйста ещё ролики по этой же теме. Например передвижение по HEX сетке)

  • @niranjanwagh5767
    @niranjanwagh5767 3 ปีที่แล้ว

    Exactly what I wanted. Please make a separate video explaining its math!

  • @CTTurboTwins
    @CTTurboTwins 2 ปีที่แล้ว

    Really great tutorial. Thanks very much!

  • @DevinDTV
    @DevinDTV 4 ปีที่แล้ว

    shouldn't this be done with instancing?

  • @AngryFaceGames_
    @AngryFaceGames_ 4 ปีที่แล้ว

    Any idea how to make this construct into a hex shaped grid?

  • @bmxpipex
    @bmxpipex 2 ปีที่แล้ว

    Hi any idea an how to make the grid move randomly over time?

  • @raptoreagle2000
    @raptoreagle2000 4 ปีที่แล้ว

    This is nice!
    i want to know how to go about animating the hexes to move up and down individually or animating the upward scaling.. (since it will give almost the same effect )

  • @gamerdweebentertainment1616
    @gamerdweebentertainment1616 4 ปีที่แล้ว

    Very Nice, but what if I wanted to do more complicated... Hexagons in Hexagon... not square. Ideally 0,0 as center?

    • @TheVoidcomp
      @TheVoidcomp 4 ปีที่แล้ว

      does Hexagons in Hexagons work? Because you can't fill a hexagon completly with hexagons like you can with squares.

  • @Nina-qt3nb
    @Nina-qt3nb 2 ปีที่แล้ว

    That's very cool. But do you know how I can make a honeycomb shape instead of a rectangular shape?

    • @michaelarby
      @michaelarby 6 หลายเดือนก่อน

      I dont know if you can do it in unreal directly, but in any 3d modelling package, make a cylinder with 6 sides. you will have to unwrap it as well, then export as an fbx.

  • @TheKitneys
    @TheKitneys 4 ปีที่แล้ว +2

    Meanwhile C4D users are scratching their heads... "Why so hard". :)

  • @icebite9888
    @icebite9888 4 ปีที่แล้ว

    Do you have any tutorials on how to make a highlight over the grid? I'm trying to figure it out but what i'm trying i don't know how to make it work.
    I made a second mesh that overlays with a material that's a transparent green just a bit above the current grid. I then turn it invisible. Now i want to turn it visible again when i mouse over the grid.
    But idk how to reference the grid itself in the controller. It's hard to find tutorials for the hex grid itself, because most of the tutorials are on square grids. Makes me almost wanna change the grid layout.

    • @Shrooblord
      @Shrooblord 2 ปีที่แล้ว

      Considering the way you've generated the grid in this tutorial actually is still using the classic 2D coordinate system of a regular square grid, almost all the logic that applies to a square grid works here too. There's some cognitive dissonance when you talk about "x1 y1" vs "x2 y1" vs "x1 y2" vs "x2 y2" in this grid because your mind wants to grab only rigid square-based coordinates and it's seeing hexes, but... yeah. You've generated the grid using simple X and Y coords, so everything that uses simple X and Y coords should work... right?
      As a leaping off point, maybe you could start with the last thing that is showcased in this video: find the coordinates of the tile under your cursor. So basically Raycast down, hit the tile grid actor, retrieve the offset from the raycast location with the tile grid actor's local zero location, iterate through the tiles and find out which tile exists at that location and use that to give back a tile ID. Once you have the ID, you can do all sorts of stuff.
      I personally don't like full grid iteration loops because the cost of doing so increases dramatically with the size of the grid. Something cleaner would be using callbacks or Blueprint Interfaces to have the tile itself report that it was hit by a raycast -- much less computationally intensive. But maybe harder to think about in design phase.

  • @王温候
    @王温候 3 ปีที่แล้ว

    感谢作者,成功帮我解决了一个困难

  • @CactuarMike
    @CactuarMike ปีที่แล้ว

    This was great! One of the few tutorials on grids that I felt I understood

  • @eugeniodelvecchio5015
    @eugeniodelvecchio5015 4 ปีที่แล้ว

    Thanks a lot!
    Great videos, keep it up!

  • @vicwaberub5297
    @vicwaberub5297 4 ปีที่แล้ว

    Nice, but why do you don't use instanced meshes (or better: hierarchical instanced meshes)? With HIDS you can build up very big grids with tentousands of hexes without any decreasments of your framerate.

    • @dawne2780
      @dawne2780 3 ปีที่แล้ว

      Would you do a tutorial? That sounds helpful

    • @vicwaberub5297
      @vicwaberub5297 3 ปีที่แล้ว

      @@dawne2780 Sorry, no time. But its easy: Just use HIDS as meshes and not static meshes. You can find a lot of videos on YT.

  • @TheRusBaron
    @TheRusBaron 4 ปีที่แล้ว

    What about materials? I mean you changed world scale, did it affect on material? They also looks scretched?

    • @underscore00
      @underscore00  4 ปีที่แล้ว +2

      The sides will stretch, but you can use materials that use world position to fix that. If you're looking for more flexibility, you can run the code at BeginPlay and instead of spawning a static mesh, you can spawn blueprint actors and then do basically whatever you want :) Hope that helps!

    • @cesarramos9547
      @cesarramos9547 4 ปีที่แล้ว

      @@underscore00 Could you make a video of this plsssss

  • @zigglyDev
    @zigglyDev 2 ปีที่แล้ว

    Thanks bro 👍

  • @mertboii3
    @mertboii3 2 ปีที่แล้ว

    very useful.

  • @Georgesbarsukov
    @Georgesbarsukov 2 ปีที่แล้ว +1

    For anyone that can't do trivial math, if you want to evenly space them then you can do some math to calculate that X/Y/offsets should be. Since the positions of the hexagons can be viewed as equilateral triangles, you can just use Pythagorean theorem on half of a triangle to calculate what Y should be relative to X. So X=X, Offset=X/2, Y=Sqrt(3)*X/2

  • @thedancenight
    @thedancenight 4 ปีที่แล้ว

    Great tutorial!

  • @ayanbahukhandi1869
    @ayanbahukhandi1869 4 ปีที่แล้ว

    You said more are comming on the FPS series where are those?

    • @underscore00
      @underscore00  4 ปีที่แล้ว +1

      On the way! I'm just a little behind with requests and other projects, but I'll be uploading 2 new episodes to the fps series in January

    • @ayanbahukhandi1869
      @ayanbahukhandi1869 4 ปีที่แล้ว

      @@underscore00 Ohh! Thank you very much I'm very excited for it...

  • @dylansmith5264
    @dylansmith5264 2 ปีที่แล้ว

    As soon as I make mine 500 x 500 it crashes ue lol whyyyyyy

  • @kenprovus9195
    @kenprovus9195 4 ปีที่แล้ว

    CAN'T UNDERSTAND YOU!

    • @elegmant
      @elegmant 4 ปีที่แล้ว

      Why?