ddb-importer
ddb-importer copied to clipboard
Templates that should be centered on tokens are not when using a hex grid
I was specifically having issues with Misty Step, but presumably it'll be an issue with anything using this sort of code to try to center something on a square:
x: token.x + canvas.grid.size / 2,
y: token.y + canvas.grid.size / 2,
Currently it's weirdly offset making the range larger on one side of the token than the other.
I switched mine to this which works for my hexagonal rows and squares:
x: token.x + canvas.grid.size * (canvas.grid.isHex ? Math.sqrt(3) / 4 : .5),
y: token.y + canvas.grid.size / 2,
Presumably you'd have to detect the type of grid for a more general solution to apply the scaling to the correct axis. For columns it would be the y that would need the sqrt(3)/4 but horizontal was all I needed.