calculating range/distance

I am trying to calculate the distance between two tokens to make sure they are in range of one another before applying an action. Though I am not sure the best way to go about this. I have tried the following which works, but it feels wrong. What is the best way to get an actors token?
// t comes from game.users.current.targets as I iterate through the current targets of the user

// needing to go from actor to the sheet to get the token seems weird!
const actorToken = actor.sheet.token;
const distance = canvas.grid.measureDistance({ x: actorToken.x, y: actorToken.y }, { x: t.x, y: t.y });
if (distance < 10) {
target = t.actor;
}
// t comes from game.users.current.targets as I iterate through the current targets of the user

// needing to go from actor to the sheet to get the token seems weird!
const actorToken = actor.sheet.token;
const distance = canvas.grid.measureDistance({ x: actorToken.x, y: actorToken.y }, { x: t.x, y: t.y });
if (distance < 10) {
target = t.actor;
}
A
aaron100d ago
actor.getActiveTokens()
E
Eclipxs98d ago
thanks! is this otherwise an ok way to go about calculating range?
Z
Zhell98d ago
Token placeables have a center getter, while if you use their x and y properties you are only getting their top left coordinates.