I’m currently making an AI pathfinding with FOV vision using dot product (vision code here).
I’m also using SimplePath for the patrolling system and I wanna ask if I can improve the code to make it more performant and efficient when chasing the player:
path:Run(pickRandomPath());
path.Reached:Connect(function()
if not PLAYER_BEING_CHASED.Value then
path:Run(pickRandomPath());
end
end)
path.Blocked:Connect(function()
warn("Path got blocked")
path:Run(currentPath);
end)
path.WaypointReached:Connect(function()
if PLAYER_BEING_CHASED.Value then
path:Run(PLAYER_BEING_CHASED.Value.Position)
end
end)
task.spawn(function()
while task.wait(0.08) do
if checkSight(monster) then
if path.Status == "Idle" then
path:Run(PLAYER_BEING_CHASED.Value)
end
else
PLAYER_BEING_CHASED.Value = nil
end
end
end)
Hey I js found a way to reduce server load a lot more. So you have to use agent parameters, and apply them to the pathfinding. these are my parameters:
the important one is waypoint spacing, the rest can be up to you. basically, the waypoints are made as far away from eachother as possible. so a lot less waypoints means much better performance. I saw a 2x increase in performance from the server.
you can check your performance by opening “script perfomance” in the roblox view panel, viewing the running game from the server, and it shows the stuff