Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. let dist = getDiaDist(...getAbsDist([clientX, clientY], [_x, _y]));
  2.  
  3. if (dist < range) {
  4. unit.x = clientX;
  5. unit.y = clientY;
  6. } else {
  7. let xx = clientX;
  8. let yy = clientY;
  9. let cc = range / dist;
  10.  
  11. unit.x = _x + (xx - _x) * cc;
  12. unit.y = _y + (yy - _y) * cc;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement