KayelGee / token-attacher

MIT License
11 stars 18 forks source link

Suggestion: Bind to center of large tokens #103

Open jonathanmclaus opened 1 year ago

jonathanmclaus commented 1 year ago

Elements attached to a token that occupies multiple squares treat the upper left square as the attach point, meaning rotating a larger token does not properly rotate the elements attached. Instead the center of the token should be considered.

KayelGee commented 7 months ago

I don't understand the issue. I've tested both a small token attached to a bigger token and vice versa. Both rotate correctly for me. Can you give me a step by step instruction to replicate what you mean? Or send me a prefab that shows this issue.

KayelGee commented 7 months ago

Still can't replicate: rotate_wide.webm

KayelGee commented 7 months ago

ohhh hex grids. Yeah there's no special code in token attacher for hex grids, so the math probably doesn't work out. Is it only tokens that have the problem? The program I used is screentogif.

KayelGee commented 7 months ago

I have a suspicion that they might've worked with hex grids aswell, as square grid works as it should from my testing

jonathanmclaus commented 7 months ago

I had issues with a square grid, but looks like it's not limited to rotation (it's just what I noticed first). In this example, I attach a 1x1 tile (size given relative to the grid, not its actual size) to a 2x2 token, offset by an entire grid square diagonally. As you can see, once transformations are applied, token attacher seems to be using only the top left square of the 2x2 token. It first scales down the tile, and then it rotates it around a single square of the token

If I detach the tile (not shown), then I can confirm it's now scaled down to 50% in each dimension.

Animation

KayelGee commented 7 months ago

I had issues with a square grid, but looks like it's not limited to rotation (it's just what I noticed first). In this example, I attach a 1x1 tile (size given relative to the grid, not its actual size) to a 2x2 token, offset by an entire grid square diagonally. As you can see, once transformations are applied, token attacher seems to be using only the top left square of the 2x2 token. It first scales down the tile, and then it rotates it around a single square of the token

If I detach the tile (not shown), then I can confirm it's now scaled down to 50% in each dimension.

Animation Animation

For me this looks like the sword was already attached to the robot before you started the gif. That's why it's offset and scale is wrong. Can you detach the sword, move and scale it to the correct position and then attach it again?

jonathanmclaus commented 7 months ago

Here's an example where I demonstrate the tile is not attached to begin with. Furthermore, it demonstrates that detaching and reattaching the same tile repeatedly iterates on the problem - the second iteration causes the tile to scale down to 25% in each dimension.

File is too big for Github, but the video can be found here: https://i.imgur.com/SYxJCTI.mp4

KayelGee commented 2 months ago

Sorry for getting back to this so late, but while your video shows what you say, I can't replicate it. This is probably some module interaction that breaks token attachers attaching.

Tarrith commented 2 months ago

The new foundry broke the game anyway. Update looks like it did some major work on the grids. I'll try again after they fix stuff.

Thanks for looking at it though.

KayelGee commented 2 months ago

I'm still in the process of updating token attacher to v12 so I didn't want to ask if you can replicate it in the current version. Once the update is out you can though.

Tarrith commented 2 months ago

Sounds like a plan :)

KayelGee commented 2 months ago

I've added a pre-release for V12 if you want to check, if the issue still persists.

jonathanmclaus commented 3 weeks ago

I still have this issue on the latest version of Token Attacher (v4.6.7). When you tested / tried to replicate it, was your token 1x1 or was it larger?

jonathanmclaus commented 3 weeks ago

To be clear, my issue is with a standard square grid. Maybe the underlying cause is the same, but my issue really has nothing to do with hex grids.