-
What do you want to achieve? I’m currently using a deprecated version of pathfinding service and I’m confused on how to convert the code into the current pathfinding system. Aka. (ComputeAsync)
-
What is the issue? For some reason whenever I use ComputeRawPathAsync, after a short time period the entire pathfinding system breaks. I even tried it with humanoid NPCS.
-
What solutions have you tried so far? I’ve tried every way in my knowledge to try to convert it into the current pathfinding system, however nothing worked. I don’t really know what i’m doing wrong. If someone could provide the code or tell me what I’m doing wrong, that would help a lot!
Code: (currently using ComputeRawPathAsync)
local part = script.Parent
local force = script.Parent:WaitForChild("Force")
local pathfind = function(start,finish)
local path = game:GetService("PathfindingService"):ComputeRawPathAsync(start,finish,500)
return path:GetPointCoordinates()
end
while true do
local positions = pathfind(part.Position,script.Parent.Parent.Parent.Finish.Position)
local oldPos = script.Parent.Parent.Parent.Finish.Position
for _,pos in next, positions do
force.position = pos
repeat
wait()
until (part.Position - pos).magnitude < 2 or (oldPos - script.Parent.Parent.Parent.Finish.Position).magnitude > 5
script.Parent.BodyGyro.CFrame = CFrame.new(script.Parent.Position , Vector3.new(pos.X, script.Parent.Position.Y, pos.Z))
if (oldPos - script.Parent.Parent.Parent.Finish.Position).magnitude > 5 then break end
end
end