Advertisement
SongJo

Gamemaker Pathfinding

Mar 21st, 2016
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (mp_grid_path(grid, path0, x,y, mouse_x,mouse_y, true))
  2. {
  3.     var i = 0, ii = 2;
  4.     while (ii < path_get_number(path0))
  5.     {
  6.         if (!collision_line(path_get_point_x(path0, i),path_get_point_y(path0, i), path_get_point_x(path0, ii),path_get_point_y(path0, ii), objectWall, true, true) && ii < path_get_number(path0) - 1)
  7.         {
  8.             ii++;
  9.         }
  10.         else
  11.         {
  12.             repeat((ii - 2) - i)
  13.             {
  14.                 path_delete_point(path0, i + 1);
  15.             }
  16.            
  17.             i++;
  18.             ii = i + 2;
  19.         }
  20.     }
  21.    
  22.     path_delete_point(path0, path_get_number(path0) - 2);
  23.  
  24.     path_start(path0, 2, path_action_stop, true);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement