I have a pathfinding script that defines the agent radius as a large number as the path is a baseline for a group of characters, but, it moves in the weirdest fashion I’ve by far ever seen.
function RunCollectionMove(finalPosition,unit)
spawn(function()
local Guider = game.ReplicatedStorage.Objects.Guider:Clone()
Guider.Parent = game.Workspace
Guider:SetPrimaryPartCFrame(unit.Parent.FlagPlaceHolder.CFrame)
Guider.PrimaryPart:SetNetworkOwner(nil)
local Path = PathfindingService:CreatePath{
AgentRadius = 45,
WaypointSpacing = 1,
AgentCanJump = false,
AgentHeight = 5,
}
Path:ComputeAsync(Guider.HumanoidRootPart.Position, finalPosition)
local Waypoints = Path:GetWaypoints()
for i,Waypoint in pairs(Waypoints) do
Guider.Humanoid:MoveTo(Waypoint.Position)
Guider.Humanoid.MoveToFinished:Wait(2)
end
end)
end
(The goal was to literally just walk through the gate)
The AI was pretty much just walking into walls thinking it could go where it clearly couldn’t, and not only that it was breaking the radius boundary by a ton
Does anyone know why the AI are picking the most inefficient possible path anyone could ever imagine?
I was working on a group pathfinding system myself a few days ago.
One thing I noticed was that the agent radius usually breaks at around 32 or more. It also breaks if the starting location is too close to other objects to begin with.
There clearly is a path here but the pathfinding system just does not want to use it.
Anyways, there are a couple of things you could do.
is to use less width size for the pathfinding. If possible don’t use it altogether as it will return very strange results sometimes.
is to create your own pathfinding system. You can use A* or you can create a map and then use the Dijkstra algorithm. It depends on how many maps you have and how much time and effort you are willing to create something like that.
is to have invisible “nogo” zones that have inf costs. (It won’t work in the real game yet.) But you can again specify where the agents should go (This is probably what I recommend you do if your game isn’t going to be released anytime soon.)
Build your map to fit the navigation mesh. The default pathfinding usually goes around the navigation areas. Its unproven that it will work. It’s just a thing you could try and see if it will work.
If you have any other problems i’d be happy to help.
Also here is the system I created not too long ago. If you are interested i’d be more than happy to help you create something like that.
Actually I would say it’s actually very easy once you get the hang of it. I recommend you watch some youtube videos and then if you understand how it works putting it into code will be easy.
The “costs” of each path between the juctions “nodes” would be the distance.
A* is one of the best pathfinding systems out there. Its actually very easy to implement once you understand it.
I recommend you look at these videos and see whether or not you can understand them or not.