#Pathfinding not updating paths in game

3 messages · Page 1 of 1 (latest)

acoustic cairn
#
local saw = script.Parent
local humanoid = saw.Humanoid

saw.PrimaryPart:SetNetworkOwner(nil)

local PathfindingService = game:GetService("PathfindingService")

local function getPath(destination)
    
    local pathParams = {
        ["AgentHeight"] = 5.2,
        ["AgentRadius"] = 4,
        ["AgentCanJump"] = false
    }

    
    local path = PathfindingService:CreatePath(pathParams)
    
    path:ComputeAsync(saw.HumanoidRootPart.Position, destination.Position)
    
    return path
end

local function walkTo(destination)
    local path = getPath(destination)
    
    for index, waypoint in pairs(path:GetWaypoints()) do
        humanoid:MoveTo(waypoint.Position)
        humanoid.MoveToFinished:Wait()
    end

end

while true do
    walkTo(workspace.destination)
    walkTo(workspace.destination2)
    
    
end

I watched this youtube tutorial of someone showcasing this code and whenever in game he changed terrain or moved a wall with resize tool from roblox studio, the npc would change his path

When i remove a wall in game, my npc still travels around it as if it is still there when he can directly get to his position

also when i add the wall when it wasnt there, my npc just passes through it as it originaly calculated when it wasnt there

acoustic cairn
#

now i tried with a maze and it was working i dont understand, but its now cutting corners and getting stuck very often

sharp briar
#

it would crash here