Hello, I’ve made some pathfinding with the new agentparams and it works fine in the studio but when going in a game it just ignores all the params and starts a normal calculations. Is there a reason it is doing this?
function OnRoute()
local DebugPart = {}
IsOnRoute = true
Humanoid.NpcDebug.OnRoute.Value = true
local agentParameters = {
AgentCanJump = true,
Costs = {
WaypointSpacing = 1,
Path = .01,
Water = 100.0
}
}
local Path = PathfindingService:CreatePath(agentParameters)
Path:ComputeAsync(StartPos, TargetPos)
--local Path = PathfindingService:FindPathAsync(StartPos, TargetPos)
local Waypoints = Path:GetWaypoints()
for waypointIndex, waypoint in pairs(Waypoints) do
local waypointPosition = waypoint.Position
local currentPosition = waypointPosition
Humanoid:FindFirstChild("NpcDebug").NextNode.Value = CFrame.new(waypointPosition)
if Settings.NpcDebug then
-- local Part1 = Instance.new("Part")
-- Part1.Parent = workspace
-- Part1.Transparency = .4
-- Part1.CanCollide = false
-- Part1.Anchored = true
-- Part1.CFrame = CFrame.new(waypointPosition)
-- Part1.Size = Vector3.new(.1, .1, 2)
local Part2 = Instance.new("Part")
Part2.Parent = workspace
Part2.Transparency = .4
Part2.CanCollide = false
Part2.BrickColor = BrickColor.new("Really red")
Part2.Anchored = true
Part2.CFrame = CFrame.new(currentPosition + Vector3.new(0, 2, 0)) * CFrame.Angles(math.rad(HumanoidRootPart.Rotation.X), math.rad(HumanoidRootPart.Rotation.Y)
,math.rad(HumanoidRootPart.Rotation.Z))
Part2.Size = Vector3.new(.1, .1, 4)
table.insert(DebugPart, Part2)
end
local waypointType = waypoint.Action
if waypointType == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid:MoveTo(waypointPosition)
repeat
Distance = (waypointPosition - Humanoid.Parent.PrimaryPart.Position).magnitude
wait()
until Distance <= 4
--Humanoid.MoveToFinished:Wait()
end
Humanoid.NpcDebug.OnRoute.Value = false
for i,v in pairs(DebugPart) do
v:Destroy()
end
StartPos = HumanoidRootPart.Position
IsOnRoute = false
end