Advertisement
minimic2002

Roblox PathFinding Script

Jun 19th, 2020
1,367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. ---Minis Pathfinding
  2. PFS = game:GetService("PathfindingService")
  3.  
  4. --CreatePathFunction
  5. function CreatePath(CharRadius,CharHeight,CanJump,StartPosition,EndPosition)
  6. --Makes sure no arguments are missing
  7. if CharRadius == nil then
  8. local CharRadius = 2
  9. end
  10. if CharHeight == nil then
  11. local CharHeight = 4
  12. end
  13. if CanJump == nil then
  14. local CanJump = true
  15. end
  16.  
  17. --Update Added this, has to be as a dictionary
  18. local PathArguments = {
  19. ["AgentRadius"] = CharRadius,
  20. ["AgentHeight"] = CharHeight,
  21. ["AgentCanJump"] = CanJump}
  22.  
  23. local Path = PFS:CreatePath(PathArguments) --Creates Path Instance
  24. Path:ComputeAsync(StartPosition,EndPosition)
  25.  
  26. --Checks To See If Path Was Found
  27. if Path.Status == Enum.PathStatus.Success then
  28. local WayPoints = Path:GetWaypoints()
  29. end
  30.  
  31.  
  32. --for i=1,#WayPoints do
  33. --Checks when it needs to jump
  34. --if WayPoints[i].Action == Enum.PathWaypointAction.Jump then
  35.  
  36. --end
  37.  
  38. --end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement