How can I prevent zombies in my tower defense game from stopping for half a second at each point they go to?


Video

Switch the goal a frame or so before they reach the goal. You might be able to use this control module which has a tested termination condition. I am also working on a more advanced pathfinder which will be building onto this controller, you can follow the progress or send feature requests here: Polaris-Nav

Honestly just replace this with

hum.MoveToFinished:Wait()

Unfortunately that method even fails to return sometimes… It is a very common issue developers have with the pathfinder, and why many alternatives have been made.

Where? It has never failed for me.

Here is one of the latest I have seen, and I have personal experience with it not working: Humanoid.MoveToFinished:Wait() Doesn't Fire Properly

2 Likes

try changing the network owner of the zombies to nil if you haven’t

How would I do that? I can try to see if it makes a difference.

loop through all the zombies and do SetNetworkOwner(nil) something like this:

for index, part in pairs(zombiesFolder:GetDescendants()) do
    if part:IsA("BasePart") then
        part:SetNetworkOwner(nil)
    end
end

Instead of making a custom wait function. Just use Humanoid.MoveToFinished:Wait()

Try this now this will work better

local hum = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")

local nodes = game.Workspace.Path1:GetChildren()

local targetReached = false
local function moveTo(targetPoint)
	targetReached = false
	local connection
	connection = hum.MoveToFinished:Connect(function(reached)
		targetReached = true
		connection:Disconnect()
		connection = nil
	end)

	-- start walking
	hum:MoveTo(targetPoint)
end

for _, node in ipairs(nodes) do
	moveTo(node.Position)
	
	
	repeat
		wait()
	until targetReached
end

I heard that there was a bug with that though on a another post. Pretty sure you just set their network owner to nil.

I’ll check it out once I’m on pc.

1 Like

For my game, I clone my zombies out of replicated storage and onto the path. Would I use that script on the clones or the ones in replicated storage?

i think you have to do it on the cloned zombies

I feel like it would make more sense doing it on the ones in replicated storage because when they get cloned, the clones also get the effect from it.

you can try both of the ways then

My bad, actually it only works on the cloned zombies because you can only change it to things in the workspace

It works though. Thanks a lot!

1 Like

It works well on my normal enemies, but I have a giant boss and it just skips a lot of the path. Is it because of it’s speed or something?