My pathfinding has been acting very weird, does anyone know why?
Here’s the code to the pathfinding:
local function MoveTo(pos)
local char = self.model
local hrp = char:FindFirstChild("HumanoidRootPart")
if not hrp then return end
local hum = char:FindFirstChild("Humanoid")
if not hum then return end
local path = PathfindingService:FindPathAsync(hrp.Position, pos)
if path then
local waypoints = path:GetWaypoints()
if waypoints then
local waypoint = checkw(waypoints)
if waypoint then
local w = waypoint
if waypoint.Action == Enum.PathWaypointAction.Walk then
hum.Jump = false
elseif waypoint.Action == Enum.PathWaypointAction.Jump then
hum.Jump = true
w = waypoints[4]
end
hum:MoveTo(w.Position)
return
end
end
end
hum:MoveTo(pos)
end
If there is a part or something in the way of the humanoid moving then it gets stuck. You can have it pathfind and every way point move to the waypoint and then calculate a new path. This could get laggy but should fix your issue.
There is no parts in the way. And FYI, his script is running in a loop. I’m not sure why it keeps randomly jumping at certain places and moving around even when there’s nothing in the way.
You would need to change the terrain and move parts around, I’m pretty sure you can’t directly change the navigation mesh sadly. Also why does your script have w = waypoints[4] for when the waypoint action is jump, what purpose does that serve?