Advertisement
anphu04

Pathfinding AI doing obby

Jul 13th, 2019
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. plr = game.Players.LocalPlayer
  2. mouse = plr:GetMouse()
  3. wait(4)
  4. print(mouse.Hit.p)
  5.  
  6. hum = plr.Character.Humanoid
  7. root = plr.Character.HumanoidRootPart
  8. a = root.Position
  9. b = Vector3.new(228,0,-6282)
  10. --b = root.Position + root.CFrame.lookVector * 30 + Vector3.new(0,-2,0)
  11. pfs = game:GetService('PathfindingService')
  12. path = pfs:ComputeSmoothPathAsync(a, b, math.huge)
  13.  
  14. for i,v in pairs(path:GetPointCoordinates()) do
  15. local p = Instance.new('Part')
  16. p.Size = Vector3.new(1,1,1)
  17. p.Position = v
  18. p.Anchored = true
  19. p.CanCollide = false
  20. p.Parent = workspace.CurrentCamera
  21. game.Debris:AddItem(p,6)
  22. end
  23.  
  24. for i,v in pairs(path:GetWaypoints()) do
  25. if v.Action == Enum.PathWaypointAction.Walk then
  26. hum:MoveTo(v.Position)
  27. hum.MoveToFinished:Wait()
  28. end
  29. if v.Action == Enum.PathWaypointAction.Jump then
  30. hum.Jump = true
  31. end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement