Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let dist = getDiaDist(...getAbsDist([clientX, clientY], [_x, _y]));
- if (dist < range) {
- unit.x = clientX;
- unit.y = clientY;
- } else {
- let xx = clientX;
- let yy = clientY;
- let cc = range / dist;
- unit.x = _x + (xx - _x) * cc;
- unit.y = _y + (yy - _y) * cc;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement