0 votes

Hi. I'm a newbie. Long time programmer but not a game/UI developer. I want to build a 2D game with a map divided up by a hexagonal grid, but I don't want to use a tileset. Instead, I want to use a hand drawn map image as the map.

However, I do want to be able to determine the center of a hex in order to place a playing piece there (for example), be able to select/highlight a hexagon by mouse click, highlight a range of hexes, perform pathfinding, etc.

I looked at the "Hexagonal Game" sample app which uses TileMap but it is tileset-based, and has very spotty mouse click support. The "hexagons" are backed by rectangles and thus not precise - I would want to be 100% precise in mouse-clicks and not have some odd guessing game of which hex will be selected when I click near an edge. However, if it did support a true hexagonal grid, I can see using it for the hit detection, placing units, and also I'm happy to use tiles from a tileset to temporarily highlight selected locations, movement ranges, etc. Is there a way to make the backing grid true hexagons?

Alternately maybe I could create my own grid with a bunch of invisible 2D polygons (hexagons) for each location that can intercept mouse clicks, have center points, etc. Would that be a resource hog on say a 100x100 (10k node) grid?

Alternately, would you do this with pure math, for example, based on the x/y coordinate calculate where on the map image to place unit sprites, whether the user clicked in a particular hex, etc.?

Your advice is appreciated. Thanks!

in Engine by (12 points)

10 days with no response! A strong sign I should use Unity instead.

I am in the same situation.
I don't need the tileset since my map is fixed. Would be happy to see a hex grid implementation which is more reliable than the one mentioned above?

As for your comment about unity, I am considering to switch if they have good hex support. Just read a lot that unity 2d is not fun to do.

I've been going back and forth between Godot and Unity trying to decide which to dive into. I'm concerned that the Godot community might be too small to provide adequate support, but I really like the approach Godot takes. I'm currently back from Unity focussing on Godot. I played with a module (romlok/godot-gdhexgrid) that might be a good starting point for you. However I'm currently thinking I can extend TileMap a bit for my needs. It already can display hexes fine. I'll report back if I resolve this.

I built just such a hexagon map-board using the MonoGame Engine. And I would be happy to share the code with you. I have provided a sample picture below...

MonoGame Hex Map Engine
There are issues with the code but fort he most part it works. I stopped working on this project because there just wasn't sufficient documentation available for MonoGame for the game development I was attempting (a strategic game of the American Revolution).

My other problem was that I am no artist and I found attempting to model the coast of the American colonies unapproachable for my skills.

In any event, I h ave also tried Unity and found it as confusing and as difficult to work with as doing a similar project by hand.

Though Unity allows for code-module support via developer created modules, in general, as your project becomes more complex so does working with Unity. Using simplistic examples on how to use and develop with Unity when most developers who are actually interested in serious game design also do not help since such examples rarely pertain to what any one developer actually wants to accomplish. As a result, Unity requires far superior tutorials for a range of game and simulation types instead of leaving to us to figure it all out...

Steve Naidamast
Sr. Software Engineer

1 Answer

0 votes

Just in case it is of interest, I recently posted a closely related question here. I started off with a relatively simple implementation, and then added a VBoxContainer with a Label and a Button to the left of the hex map.

by (16 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.