godotengine / godot-proposals

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

Support half-offset square grids for `GridMap` #4386

Open octetdev2 opened 2 years ago

octetdev2 commented 2 years ago

Describe the project you are working on

Godot engine improvements.

Describe the problem or limitation you are having in your project

There is no built-in support for half-offset square grids in GridMap.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Builds on https://github.com/godotengine/godot-proposals/issues/4337 and adds half-offset squares as a new cell shape.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Cell shape is extended to include triangles

enum CellShape {
  CELL_SHAPE_SQUARE,
  CELL_SHAPE_HALF_OFFSET_SQUARE,
  CELL_SHAPE_HEXAGON,
};

image

If this enhancement will not be used often, can it be worked around with a few lines of script?

It cannot.

Is there a reason why this should be core and not an add-on in the asset library?

For feature parity with TileMap and the GridMap is in core.

Calinou commented 2 years ago

Out of curiosity, how popular are half-offset square tile layouts in 3D games? Compared to hexagon layouts, I don't see them often.

Do half-offset square tiles have peculiar properties that make them interesting to use in certain scenarios, like hexagon or triangle tiles?

octetdev2 commented 2 years ago

Out of curiosity, how popular are half-offset square tile layouts in 3D games? Compared to hexagon layouts, I don't see them often.

Do half-offset square tiles have peculiar properties that make them interesting to use in certain scenarios, like hexagon or triangle tiles?

Honestly, I don't know or have any amazing use cases for this one.

My main motivation for this one is for parity so there can be one TileShape enum applicable to both TileMap and GridMap with no need for duplication in the world <-> tile space math or have any oddly named CELL constants.

I assume they would be as useful as they are in two dimensional TileMaps. The grid is the same after-all, GridMap just stacks up in height.

Mickeon commented 2 years ago

I'm all up for making GridMap essentially be TileMap but with one extra dimension, although I really struggle to think of anything for this proposal, even if it'd be nice.

In my game, I use a half-offset TileMap for a hexagonal tileset (think of Puzzle Bubble bubbles), so the only use I can think of this would be the around the same, but with 3D models.

Mickeon commented 2 years ago

I'm sure there will be very creative individuals making use of the shapes being proposed in the past, but I have to question if their limited need warrants introducing some way to define CUSTOM cell shapes/grids, instead...