I’m very new to coding and am trying to create a hexagon grid, turn based movement system. Ive watched the hexagon tutorials on other sites and they work fine, i just dont understand the code fluently enough to really use. Heres my idea: i know how to generate a hexagon grid and show which hexagon the mouse is hovering over and selected. Then, with the a* pathfinding system, i create a point graph and put each node in the center of each hexagon so that when i select a hexagon, its actually selected the node from the graph and moves the character there. That way i at least know whats going on and could maybe proceed to creating some type of system where each character can only move a certain amount of nodes each turn? Possible or ridiculous to even try? (or since im creating the hexagon grid by instantiating a hexagon object prefab, i could just tag that object as the waypoint node.)
So it kinda works, however instead of traveling along the path of hexagons, apparently in a point grid, every node is connected to every other, so the character cuts through directly to the node its traveling to. is there a way to limit the connections between nodes so that a character must travel to each node to get to the next one and so on until it reaches the target node its traveling to, if that makes sense…?
Thanks for the answer! Much appreciated! The graph and pathfinding system works great. Thanks for the code and making help available.
Hi
You would set the “Max Distance” field on the point graph to something just slightly larger than the distance between two adjacent hexagons. That will create you the grid you want.
Also, you will probably want to turn on “Optimize For Sparse Graph” and “Optimize for 2D” to reduce the graph calculation times.