ddb-importer icon indicating copy to clipboard operation
ddb-importer copied to clipboard

Templates that should be centered on tokens are not when using a hex grid

Open seanpg71 opened this issue 3 years ago • 0 comments

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.

seanpg71 avatar Sep 06 '22 03:09 seanpg71