#Hexagonal Tilemap Coordinates

1 messages · Page 1 of 1 (latest)

olive skiff
#

Hello, I have a problem with my coordinate search system on a flat top hexagonal grid. I have tried several methods such as using an offset, using q r s coordinates, if anyone can help me 🙂

fickle shard
olive skiff
#

I've already looked at this great documentation, but I can't seem to apply it

warm eagle
olive skiff
grand lagoon
#

I did something like this custom recently and i only used vector2int for positions
x being odd/even is used to correct the neighbours retrieved

#

Here is a snippet of this. The y offset column is different to the unity grid component

int yOffset = (pos.x + 1) % 2;
Span<Vector2Int> neighbourPositions = stackalloc Vector2Int[6]
{
                                new (pos.x, pos.y + 1),
new(pos.x - 1, pos.y + 1 - yOffset),                   new(pos.x + 1, pos.y + 1 - yOffset),
new(pos.x - 1, pos.y + 0 - yOffset),                   new(pos.x + 1, pos.y + 0 - yOffset),
                                new(pos.x, pos.y - 1)
};