Advertisement
Badwrong

GameMaker - Instance Nearest Second

Apr 11th, 2021 (edited)
942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function InstanceNearestNotMe(_object)
  2. {
  3.     var _realX = x;
  4.     x = x << 5;
  5.     var _nearest = instance_nearest(_realX, y, _object);
  6.     x = _realX;
  7.     if (_nearest == id) return noone;
  8.     return _nearest;
  9. }
  10.  
  11. function Instance2ndNearest(_object)
  12. {
  13.     if (instance_number(_object) < 3) return noone;
  14.     var _realX = x;
  15.     x = x << 5;
  16.     with instance_nearest(_realX, y, _object)
  17.     {
  18.         var _nearX = x;
  19.         x = x << 5;
  20.         var _nearest = instance_nearest(_nearX, y, _object);
  21.         x = _nearX;
  22.     }
  23.     x = _realX;
  24.     return _nearest;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement