Advertisement
tyridge77

Untitled

Sep 10th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1.  
  2. local PathFinder = require(ReplicatedStorage.Modules.PathFinding);
  3. local findPath = PathFinder.findPath
  4. local findClosestNode = PathFinder.findClosestNode;
  5.  
  6. local function FindPath(start,destination)
  7.     local foundnode = findClosestNode(start);
  8.     local foundend = findClosestNode(destination);
  9.     if foundnode and foundend then
  10.         local foundpath = findPath(foundnode,foundend);
  11.         if foundpath then
  12.             local temp = {};
  13.             for i,v in pairs(foundpath) do
  14.                 temp[i]=v.Position;
  15.             end
  16.             return temp;
  17.         else
  18.             return nil;
  19.         end
  20.     else
  21.         error("Closest node(s) not found!");
  22.     end
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement