Hello, I am currently creating a tower defense game where waves of enemies move from one point to another along a specified path. I am using PathfindingService to do this, although the enemies only move at random. Sometimes they begin walking perfectly normal, other times they don’t move at all and CreatePath() returns NoPath. I’ve tried multiple solutions including changing the AgentHeight, moving collideable objects away from the path, but none of them worked. I have never come across a problem like this using PathfindingService, so I am completely stumped.
The code that moves enemies:
local function MoveEnemy(Model)
local EnemyModel = Model
local Humanoid = EnemyModel.Humanoid
if Humanoid == nil then print("Humanoid is nil") return end
local EndPoint = WaypointsFolder.EndPoint
local Path = PathFindingService:CreatePath()
Path:ComputeAsync(EnemyModel.HumanoidRootPart.Position, EndPoint.Position)
if Path.Status == Enum.PathStatus.Success then
local Waypoints = Path:GetWaypoints()
local Success, ErrMsg = pcall(function()
for i, v in pairs(Waypoints) do
Humanoid:MoveTo(v.Position)
Humanoid.MoveToFinished:Wait()
end
end)
if not Success then
warn(ErrMsg)
end
else
warn(Path.Status)
end
end
If you have a potential solution, please reply. Thank you