godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.1k stars 69 forks source link

Add support for hexagonal GridMaps #472

Closed KnightNine closed 6 months ago

KnightNine commented 4 years ago

Describe the project you are working on: A turn based strategy game that takes place in a 3d hexagonal prism grid.

Describe the problem or limitation you are having in your project: There's no functionality for different types of grids beyond cubes and squares for level creation in the editor.

If there was a setting to have cells within the grid ignore the gridmap's transforms, it would be plausible to place the cells at points that would be in line with a hexagonal grid. But even then, I see no way to store irrational numbers as transform values of the gridmap node to have it line up perfectly with the hexes.

Describe the feature / enhancement and how it helps to overcome the problem or limitation: It would be an alternative arrangement for the gridmap that would allow for the placement of hexagonal prisms. It would help with accommodating for the usage of hex based grids within the editor as opposed to having to create an application for this specific purpose that the gridmap is already meant to fulfill.

(This could also apply to the 2d tilemap module but 2d sprites don't require the same level of precision that this does and sprites aren't necessarily warped by the grid transforms.)

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: what this grid would look like: grid Instead of creating a whole new gridMap with a hexagonal grid, the existing Gridmap could be adapted to accommodate for the positions that would be needed.

This would need to be enabled as a setting as being the new default transform values for the gridmap's spatial in order to not have it affect the transform values of the gridmap's children/cells.

If this enhancement will not be used often, can it be worked around with a few lines of script?: It cannot be worked around without editing the gridmap module and compiling a custom version of godot since I don't believe plugins to have the level of functionality required for this type of modification. A level editor could be made from scratch that you'd have to run as an application, but in that case it cannot be used within the editor. Many games use hexagonal tiling as there are reasons for hexes to be used over squares and cubes so I believe it could potentially be relevant to any project with a grid.

Is there a reason why this should be core and not an add-on in the asset library?: It is inconvenient to have the level editor run as a separate application, especially when it is someone else's work that could be based in one of many different types of coordinate systems and have to translate it to your own project. I haven't tried it yet since I would be more comfortable with creating a separate application alltogether, but I also don't believe it to be possible to be created as a plugin with the same functionality as gridmaps from what I've seen of custom plugins. Though I could be wrong as I am not very experienced in making them.

Zireael07 commented 4 years ago

I believe the same thing is necessary for 2D, too.

Calinou commented 4 years ago

For 2D, does the 2d/hexagonal_map demo in the godot-demo-projects repository fill this need?

KnightNine commented 4 years ago

For 2D, does the 2d/hexagonal_map demo in the godot-demo-projects repository fill this need?

Oh, Well I guess 2D can accommodate for hex/iso tiles since the sprites aren't affected by the tilemap's shape in that demo and sprite hexes don't require the same level of precision as 3d mesh grids.

Xrayez commented 4 years ago

The Battle for Wesnoth is currently being ported to Godot which does seem to use hexagonal tilemaps hacked together. Given how there's a requirement for functionality consistency between 2D and 3D nodes, the gridmap should receive similar treatment in my opinion.

clayjohn commented 4 years ago

Gridmaps are included in the list of proposed work products that Juan shared on Twitter last week. This is likely something that could be considered with that.

Although, I wonder. Can the same method for 2D not be done for 3D as well? E.g. shifting the rows. It seems to work fine for 2D.

Seel commented 4 years ago

Shifting the rows works in 2D, but wouldn't you get inconsistent results with map to world and world to map by doing it like that? Since the hex tile would be bigger and have a different shape to the underlying rectangular grid.

Anyway I'm in favor of this and a dedicated hex mode for 2d as well, with flat topped and pointy topped options.

KnightNine commented 4 years ago

Shifting the rows works in 2D, but wouldn't you get inconsistent results with map to world and world to map by doing it like that? Since the hex tile would be bigger and have a different shape to the underlying rectangular grid.

Anyway I'm in favor of this and a dedicated hex mode for 2d as well, with flat topped and pointy topped options.

I'm not sure what you mean by "map to world and world to map"? The appearance of the underlying rectangular grid would not be functionally different from a hexagonal grid no?

You'd be able to rotate the grid 90 degrees for pointy topped hexes but the potential issue with that would be that the coordinate system wouldn't change relative to the axes so maybe that option should also be implemented.

Janglee123 commented 4 years ago

This is a good option if you need any extra features for hex tile map. https://github.com/romlok/godot-gdhexgrid

Calinou commented 3 years ago

Closing in favor of https://github.com/godotengine/godot-proposals/issues/1769. Note that support for hexagonal tiles has been implemented in the new TileMap/TileSet editor which will be available in Godot 4.0.

KoBeWi commented 3 years ago

I think the discussion got derailed into 2D too much and the proposal was closed by mistake. It's about 3D and GridMaps, so #1769 is unrelated. (reopening was requested on chat)

eranimo commented 2 years ago

Any hope of getting this in 4.1? Is there any workaround that is acceptable in 3.x?

PeterMarques commented 1 year ago

There is already suport... You just need to use this image

Kangarroar commented 1 year ago

Closing in favor of #1769. Note that support for hexagonal tiles has been implemented in the new TileMap/TileSet editor which will be available in Godot 4.0.

So, we are in godot 4, no hex gridmap

Calinou commented 1 year ago

So, we are in godot 4, no hex gridmap

There is support for hexagonal tiles in 4.0, as mentioned in the updated Using TileSets documentation.

If you need additional documentation on creating hexagonal tilesets, please open an issue on https://github.com/godotengine/godot-docs.

KoBeWi commented 1 year ago

The issue is about hexagonal GridMap (3D), not TileMap (2D).

Pablokiryu commented 10 months ago

octetdev has implemented this in his own module .

perroboc commented 6 months ago

octetdev has implemented this in his own module .

Hopefully this can be integrated or merged!

Calinou commented 6 months ago

Closing in favor of https://github.com/godotengine/godot-proposals/issues/4337, as that proposal has a concrete technical implementation.