What do you want to achieve?
I want my NPCs to move to each waypoint without pausing for a second per one.
What is the issue?
My NPCs will be fine for the first minuet of the game. But Later into the game they tend to stop at each waypoint. I have my pathfinding all in one function. Sometimes when the function runs, there’s no problem at all. Other times, they can pause for up too 2 seconds per waypoint. In some cases the NPC has exploded. and mangled itself?
What solutions have you tried so far?
Ive tried, Setting the Network ownership of all the baseparts to Nil,
Changing the wait between waypoints from a repeat wait() until Distance. To Humanoid.MoveToFinished:Wait(),
Having the NPCs cloned from Replicated storage instead of Lighting,
Using RunService.Heartbeat:Wait() Instead of just Wait(),
Checking other forum posts to find a solution but either it wasn’t the same problem or they had no solution.
Extra info
Then NPC is 1.5x the standered NPC proportions so hes a little bit chonk
Most of the paths are small and straight lines with little waypoints.
I’ve changed it so the waypoint height is always Torso height. as the NPC is always walking on a flat surface more or less in a straight line (This is because the waypoints spawn at the feet and sometimes go underground?)
CODE:
function Travel(Position)
--Create Path
local PathParams = {AgentRadius = 2.5, AgentHeight = 9, AgentCanJump = false ,WaypointSpacing = 3}
local Path = PathfindingService:CreatePath(PathParams)
local success, errorMessage = pcall(function()
Path:ComputeAsync(script.Parent.HumanoidRootPart.Position, Position)
end)
local WayPoints = Path:GetWaypoints()
--MoveToPoint
WalkAnimationTrack:Play()
wait()
for i = 1,#WayPoints do
local WaypointPosition = WayPoints[i].Position
local NewPosition = Vector3.new(WaypointPosition.X,script.Parent:WaitForChild("HumanoidRootPart").Position.Y, WaypointPosition.Z)
script.Parent.Humanoid:MoveTo(NewPosition)
repeat
local distance = (NewPosition - script.Parent:WaitForChild("HumanoidRootPart").Position).magnitude
RunService.Heartbeat:Wait()
until distance <= 2.5
end
script.Parent.humanoid:MoveTo(Position)
if Path.Status == Enum.PathStatus.NoPath then
warn("No Path")
elseif Path.Status ~= Enum.PathStatus.NoPath then
print("Successful Travel")
end
WalkAnimationTrack:Stop()
end
Please help me, Ive been stuck on this for weeks!
Regards ~ Anon