Hi, I’m making a tower defence style game and I’m using moveto() to make the zombies walk along the path. It works perfectly fine, except for when they walk towards one of the parts (there is only one part that has the issue), they turn and head towards the next part before actually reaching the previous part. Any ideas why this is?
You can check when the model finishes its :MoveTo journey by using this event:
MoveToFinished
…and then when it’s finished moving, you can move them to the next part
I think I’m already doing that, its weird because it works perfectly fine for all the other parts its just that one.
function mob.Move(mob, map)
local humanoid = mob:WaitForChild("Humanoid")
local waypoints = map.Waypoints
for waypoint = 1, #waypoints:GetChildren() do
humanoid:MoveTo(waypoints[waypoint].Position)
humanoid.MoveToFinished:Wait()
end
mob:Destroy()
end
Another thing I found is there is only 1 type of zombie that skips it, all the others walk to it with no problems.
Try to add more parts on mob way near this part which bugged.
The move to finished has a timeout value. This means it will turn earlier.
Furthermore, it’s unreliable I recommend just checking the distance from the target in a loop, and then when it reaches close enough it switches to the next point.
I have had the same problem previously with a Tower Defence project if you need any more help feel free to ask.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.