Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you proof read this pathfinding algorithm?

Asked by 9 years ago

So I made two Humanoid people. One of them is named AI and the other Test. At first when I ran the script it would make the character move to to the Test's direction, but just in a straight line. Which means I had to make a loop right? So I did, and now it doesn't move at all!Plus I have no output... Please help guys.

~The Script~

01local a = game.Workspace:FindFirstChild("Test")
02local b = script.Parent
03 
04 
05if a then
06 
07local path = game:GetService("PathfindingService")
08 
09while  wait(4) do
10local route = path:ComputeRawPathAsync(b.Torso.Position, a.Torso.Position, 200)
11    if route.Status == "Enum.PathStatus.Success" then
12    b.Humanoid:Move(a.Torso.Position)
13 
14 
15    end
16 
17    end
18end
4
my eyes drew1017 330 — 9y
0
Lol drew. But yes, putting that into Lua format would be a lot less strenuous to observe. CodingEvolution 490 — 9y
0
ohh mistaLangston 10 — 9y
0
Wait how? mistaLangston 10 — 9y
View all comments (6 more)
0
Edited your question for you. Enjoy. Unclear 1776 — 9y
0
Just from taking a short look i can tell you're going to have a problem with that if statement and string. Comparing route.Status to a string will return false because you're not comparing it with the actual Enum value. CodingEvolution 490 — 9y
0
But that's about all i'm useful for here. I haven't looked at the PathFinding API yet. CodingEvolution 490 — 9y
0
Well it at least got it moving now that I fixed it and thank you Ayonjun! mistaLangston 10 — 9y
0
Come on please help someone? mistaLangston 10 — 9y
0
I can look into PathFinding and help you. But i'm going to bed now. CodingEvolution 490 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago
1local a = game.Workspace:WaitForChild("Test")
2local b = script.Parent
3local path = game:GetService("PathfindingService")
4-- I'm not sure why you're using a loop. It usually only has to run ONCE to get to the point. Or else major lag would occur.
5local route = path:ComputeRawPathAsync(b.Torso.Position, a.Torso.Position, 200)
6   if route.Status == Enum.PathStatus.Success then
7     b.Humanoid:WalkToPoint(a.Torso.Position) -- Changed to WalkToPoint because Move isn't a thing?
8end
Ad

Answer this question