The following is an AI for a zombie pathfinding system that moves the zombie along Vector3 coordinates dictated by the real brains behind my pathfinding system (an A* solution). My problem is that, even though I put in a section to deal with this problem, the zombie only moves to the first Vector3 value given.
Can anyone see my mistake/oversight?
print("ZOMBIE PATHFINDING AI: PATHFINDING INITIATED")
firsttime = true
while wait() do
target = script.Parent.nearestTorso.Value
print("ZOMBIE PATHFINDING AI: TARGET FOUND")
targetPath = _G.generatePath(script.Parent.Torso.Position, target.Position, true)
print("ZOMBIE PATHFINDING AI: PATH TO TARGET CALCULATED")
numberOfNodes = 0
for Index, Child in pairs(targetPath) do
numberOfNodes = numberOfNodes + 1
end
print("ZOMBIE PATHFINDING AI: PATH COMPLEXITY = "..tostring(numberOfNodes))
-- y = 1
-- for Index, Child in pairs(targetPath) do
if targetPath then
if firsttime == true then
script.Parent.Zombie:MoveTo(targetPath[1].Value, target)
print("ZOMBIE PATHFINDING AI: MOVING TO VECTOR3 POSITION ["..tostring(targetPath[1].Value).."]")
wait(8/script.Parent.Zombie.WalkSpeed + 0.1)
firsttime = false
else
script.Parent.Zombie:MoveTo(targetPath[2].Value, target)
print("ZOMBIE PATHFINDING AI: MOVING TO VECTOR3 POSITION ["..tostring(targetPath[2].Value).."]")
wait(8/script.Parent.Zombie.WalkSpeed + 0.3)
end
else
print("ZOMBIE PATHFINDING AI: NO SUITABLE VECTOR3 NODE FOUND")
wait(0.5)
print("ZOMBIE PATHFINDING AI: REBOOTING...")
script.Disabled = true
end
-- repeat wait() until (targetPath[y].Value - script.Parent.Torso.Position).magnitude < 6
-- y = y + 1
-- end
print("ZOMBIE PATHFINDING AI: PATHFINDING FUNCTION HAS LOOPED")
end
If it's helpful, I continuously get
ZOMBIE PATHFINDING AI: PATH TO TARGET CALCULATED ZOMBIE PATHFINDING AI: PATH COMPLEXITY = 20ZOMBIE PATHFINDING AI: MOVING TO VECTOR3 POSITION [118.600006, 15.1999998, 48]
to print out from the output.
Thanks in advance

2 comments
Please try to make the title reflect the question, or at least the contents of it. Thanks.
How do I 'bump' my post? Through a comment like this?