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

How to I get this pathfinder to stop stuttering?

Asked by 9 years ago
repeat wait() until workspace:FindFirstChild("Player")
local player1 = game.Workspace.Player
local player = script.Parent
game:GetService("PathfindingService").EmptyCutoff = 0

while (math.abs(script.Parent.Torso.Position.Magnitude - workspace.Player.Torso.Position.Magnitude)) > 5 do --Try that
    w = script.Parent.Torso.Position.Magnitude
    r = workspace.Player.Torso.Position.Magnitude
    print(math.abs(w-r))
    local start = game.Workspace.NPC.Torso
    local fin = player1.Torso
    path = game:GetService("PathfindingService"):ComputeSmoothPathAsync(start.Position,workspace.Player.Torso.Position,400)
    points = path:GetPointCoordinates()
    divide = #points*5

for i, v in pairs(points) do
    player.Humanoid:MoveTo(v)
    wait(#points/divide)
    p = Instance.new("Part", workspace.Points)
    p.Size = Vector3.new(1,1,1)
    p.Position = v
    p.Anchored = true
    p.Name = "Point"
    p.CanCollide = false
    p.Transparency = 1
    if pos then
        if pos < p.Position.y then
            player.Humanoid.Jump = false
        end
    end
    pos = p.Position.y
end


end

Everytime this player completes a :moveto(), it stutters a little bit and it makes the movement look inhuman. How do I change this?

Answer this question