Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Path finding errors, not able to create path?

Asked by 3 years ago
Edited 3 years ago

Hello, I am working on path finding for a zombie AI and it seems that when the zombie is spawned in the game and you are behind a cancollided wall he will create a path. He will find you in the players and label you a target, but he can't create a path to you, but no errors pop up. It seems as if it is just a bug that I don't know how to fix. I was wondering if there was a way to fix this, or to check to see if a path was created, and if it wasn't created maybe he can be deleted from the workspace and respawned somewhere else. I am not quite sure how to check if a path was created. Could anyone give me some pointers?

Here is my code:


function findPath(target) showImage() local path = game:GetService("PathfindingService"):CreatePath() path:ComputeAsync(myRoot.Position,target.Position) local waypoints = path:GetWaypoints() local success = path.Status == Enum.PathStatus.Success if success then for _, waypoint in ipairs(waypoints) do if waypoint.Action == Enum.PathWaypointAction.Jump then myHuman.Jump = true end myHuman:MoveTo(waypoint.Position) local timeOut = myHuman.MoveToFinished:Wait(1) if not timeOut then myHuman.Jump = true print("Path too long!") findPath(target) break end if checkSight(target) then repeat --print("Moving directly to the target") myHuman:MoveTo(target.Position) attack(target) wait(0.1) if target == nil then break elseif target.Parent == nil then break end until checkSight(target) == false or myHuman.Health < 1 or target.Parent.Humanoid.Health < 1 break end if (myRoot.Position - waypoints[1].Position).magnitude > 20 then print("Target has moved, generating new path") findPath(target) break end end end end

1 answer

Log in to vote
0
Answered by 3 years ago

The answer is simple.. u didn't call the function findPath()

0
function main() showImage() local target = findTarget() if target then myHuman.WalkSpeed = 16 findPath(target) else print("else") myHuman.WalkSpeed = 8 walkRandomly() end end Channy97 10 — 3y
Ad

Answer this question