Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I bypass FailStartNotEmpty?

Asked by 9 years ago

I'm trying to use the new PathfindingService to implement AI into some zombies.

However, when I try to use the StartPoint of a Zombie's torso, the path's Status returns "FailStartNotEmpty".

No duh, Roblox. It's not supposed to be.

But, I cannot continue without this, so is there anyway I can tell it to ignore the Zombie Torso part when creating the path?

If you think the code will help, here it is. It's lengthy and part of a ModuleScript.

function myModule.Pathfind(zombie)

    local pathfindingService = game:GetService("PathfindingService")
    local start = zombie.Torso.Position
    local target = zombie.nearestTorso.Value.Position
    local path = pathfindingService:ComputeRawPathAsync(start, target, 500)

    -- Check to see if the path was computed correctly
    if path.Status == Enum.PathStatus.FailStartNotEmpty then
        print("Compute Failed: FailStartNotEmpty")
        return {}
    elseif path.Status == Enum.PathStatus.FailFinishNotEmpty then
        print("Compute Failed: FailFinishNotEmpty")
        return {}
    end 

    targetPath = path:GetPointCoordinates()
    numberOfNodes = #targetPath

    if container ~= nil then
        targetpointchil = container:GetChildren()

        for i=1, #targetpointchil do
            targetpointchil[i]:Destroy()
        end

        for i, v in pairs(zombie.CurrentPath:GetChildren()) do
            v:Destroy()
        end 

        container:Destroy()
    end

    container = Instance.new("Model")
    container.Name = "TargetPointHolder"
    container.Parent = Workspace    

    for i, v in pairs(targetPath) do
        if (v - zombie.Torso.Position).magnitude < (zombie.nearestTorso.Value.Position - zombie.Torso.Position).magnitude then
            nodeLocation = Instance.new("Vector3Value")
            nodeLocation.Name = "Point"..i
            nodeLocation.Value = v
            nodeLocation.Parent = zombie.CurrentPath

            targetpoint = Instance.new("Part")
            targetpoint.Name = "TargetPoint"
            targetpoint.Anchored = true
            targetpoint.CanCollide = false
            targetpoint.FormFactor = "Custom"
            targetpoint.Size = Vector3.new(0.2, 0.2, 0.2)
            targetpoint.Transparency = 1
            targetpoint.Parent = container
            targetpoint.CFrame = CFrame.new(v)

            targetpointreference = Instance.new("ObjectValue")
            targetpointreference.Value = targetpoint
            targetpointreference.Name = "Reference"
            targetpointreference.Parent = nodeLocation
        end
    end
end

Answer this question