Hey everyone!
I’m using a single script to control multiple enemies. The pathfinding MoveToFinished plays the idle animation when calculating the next waypoint position for the zombie. It causes a slight stutter in the animation. Is there any workarounds for this?
I’ve tried different approaches (i.e, calculating the magnitude) but they lose the pathfinding and easily get confused/stuck.
Any help or suggestions are greatly appreciated!
Best, Water
function pathToTarget(zombie)
local path = game:GetService("PathfindingService"):CreatePath()
path:ComputeAsync(zombie.root.Position,zombie.target.Position)
local waypoints = path:GetWaypoints()
local currentTarget = zombie.target
local distance
--print(waypoints)
for i, v in pairs(waypoints) do
if v.Action == Enum.PathWaypointAction.Jump then
zombie.human.Jump = true
else
zombie.human:MoveTo(v.Position)
zombie.human.MoveToFinished:Wait()
if not zombie.target then
print("no zombie.target")
break
elseif checkDist(currentTarget,waypoints[#waypoints]) > 10 or currentTarget ~= zombie.target and zombie.target:FindFirstChild("Playing") then
pathToTarget(zombie)
print("pathToTarget")
if v.Action == Enum.PathWaypointAction.Jump then
zombie.human.Jump = true
zombie.human:MoveTo(zombie.target.Position)
end
break
end
end
end
end