|
It's all in the tutorial, if u read between the lines:
Path-finding uses the stardard (Terrain?) grid as the nodes, so every Point is going to be on that grid, 0,0,4; 0,4,8; 16,40,8
So u gotta build your place on that grid, or Humnoid's Shoulders clip the walls.
I guees u can get a grid to build on, by just temporarily covering your entire place in Terrain; then deleteing it.
2)
This does not entirely solve your second problem, but it tries to massage the Path search, if PathService returns an error. It stops about 99% of non-returns, but after calling it, u should still check Path.Status to make sure u got a path[ else do something else? Jump in a random direction?:
function ReturnPath(start, finish, MaxDist)
local path = pathfinding:ComputeRawPathAsync(start, finish, MaxDist)
print (path.Status)
if path.Status == Enum.PathStatus.FailFinishNotEmpty then
local dist = (finish - start).magnitude
while dist > 8 and path.Status == Enum.PathStatus.FailFinishNotEmpty do
wait()
finish = start + (finish - start)/1.5
path = pathfinding:ComputeRawPathAsync(start, finish, MaxDist)
dist = (finish - start).magnitude
local part = Instance.new("Part", Workspace)
part.FormFactor = Enum.FormFactor.Custom
part.Size = Vector3.new(4,4,4)
part.CFrame = CFrame.new(finish)
part.Shape = "Ball"
part.Anchored = true
part.CanCollide = false
part.BrickColor = BrickColor.Red()
table.insert(Showed, part)
end -- room to manuveur?
Bot.ShowPath (start, finish)
end -- finish error
if path.Status == Enum.PathStatus.FailStartNotEmpty
or path.Status == Enum.PathStatus.ClosestNoPath then
wait()
start = start + Vector3.new(0,0,4)
path = pathfinding:ComputeRawPathAsync(start, finish, MaxDist)
if path.Status == Enum.PathStatus.FailStartNotEmpty
or path.Status == Enum.PathStatus.ClosestNoPath then
start = start + Vector3.new(4,0,-4)
path = pathfinding:ComputeRawPathAsync(start, finish, MaxDist)
end
if path.Status == Enum.PathStatus.FailStartNotEmpty
or path.Status == Enum.PathStatus.ClosestNoPath then
start = start + Vector3.new(-4,0,-4)
path = pathfinding:ComputeRawPathAsync(start, finish, MaxDist)
end
if path.Status == Enum.PathStatus.FailStartNotEmpty
or path.Status == Enum.PathStatus.ClosestNoPath then
start = start + Vector3.new(-4,0,-4)
path = pathfinding:ComputeRawPathAsync(start, finish, MaxDist)
end
Hum:MoveTo(start)
wait()
end -- start error?
return path -- should prolly Return 'finish', as well. Ifinnidh does not equal the 'finnish' that u supplied, then it may have returned a Path, but a truncated path.
GL
end--Return Path
|