So the title may be a little confusing, since I’m not a native english speaker but I’ll try to explain it as best as I can. So I have a relatively medium-large sized map.
If the pathfinder AI chases players, then that might be a problem for the pathfinder. But neither cases should bug out the pathfinder; though you can use a bigger collider block (or just disable the collisions on the decorations as that also consumes memory)
I might be actually using PS wrong here, cause when I fire the :AdvanceDistance(), it returns with 0 waypoints?
This is the code:
function module:AdvanceDistance(p1, p2, extraPathData)
local path = PathfindingService:CreatePath(extraPathData)
path:ComputeAsync(p1, p2)
local waypoints = path:GetWaypoints()
print(#waypoints)
local totalDistance = 0
for i, waypoint in pairs(waypoints) do
local nextWP = waypoints[i + 1]
if nextWP then
totalDistance += (waypoint.Position - nextWP.Position).Magnitude
end
end
return totalDistance, waypoints
end
This is where it gets called from:
local function properMoveTo(p1, p2, humanoid)
local distance, waypoints = LocalAPI:AdvanceDistance(p1, p2, PathfindingData)
local targetWaypoint = waypoints[PathfindingSettings.SkipToWP]
warn(distance, waypoints)
for _, v in pairs(waypoints) do
debugg(v.Position)
end
if targetWaypoint then
warn(LocalAPI:GetDistance(p1, targetWaypoint.Position), "target wp", #waypoints)
debugg(targetWaypoint.Position)
humanoid:MoveTo(targetWaypoint.Position)
else
warn(LocalAPI:GetDistance(p1, p2), "no target")
debugg(p2)
humanoid:MoveTo(p2)
end
print("a")
end
Output shows: 0 {}
0 Being the distance from p1 and p2 according to waypoints, and {} is the table of the waypoints.
It may be because the path is unreachable/impossible for the pathfinder to find one valid solution (check the environment and your extra path data), try printing the path status enum
are you sure from the starting point to the destination is reachable? can you provide the pathfinder agent parameters and a screenshot of the starting point and the destination?
The map is entirely basically a maze, the starting point is somewhat center of the map and destination is a random waypoint out of ~100. Also I got it to partially work, apparently AgentHeight was messing it up a bit. But it’s still iffy, however I’ll try maybe messing with the params to possibly get a fix
I think I got it to work, I’mma try sum to check
Edit: Yup I fixed it, technically fixed it myself but I’ll give @Artzified the solution cause you helped me out still