Need help with Army Pathfinding

I cannot figure out how to replicate a AI from a game called “Noob Army Tycoon”, I tried pathfinding but it doesn’t come out how I wanted it to.

Reference:

My Pathfinding:

UnitManager.GetPath = function(Location : Vector3, Unit : Model)
	local path : Path = PS:CreatePath({
		["AgentCantJump"] = false,
		["AgentCanClimb"] = false,
		["AgentRadius"] = 10,
		["AgentHeight"] = 3,
		["WaypointSpacing"] = math.huge,
		["Costs"] = {
			Water = math.huge,
			Concrete = math.huge,
			Grass = math.huge,
			Ground = 0,
			Path = 0,
		}
	})
	path:ComputeAsync(Unit:WaitForChild("HumanoidRootPart").Position,Location)
	return path
end

UnitManager.Walk = function(plr : Player, Unit : Model)
	local hum : Humanoid = Unit:WaitForChild("Humanoid")
	
	local getPath = UnitManager.GetPath(workspace.Workspace.Points.Center.Position,Unit)
	print(getPath:GetWaypoints())
	for _,waypoints in pairs(getPath:GetWaypoints()) do
		hum:MoveTo(waypoints.Position)
		hum.MoveToFinished:Wait()
	end
	
end
1 Like

Bump, i need someone to atleast try to help me :pray:

If I remember correctly, the noobs in noob army tycoon always walk in a straight line, so they don’t even use pathfinding (hence naturally not clumping up). I think there are some topics on here about making zombies chase after a player without forming a conga line, which might be instructive (see also: Boids.

Edit: Found it

I’m not very experienced with AI, and im not sure where to even start with it. All i did was use the basic pathfinding

In a nutshell, call the move to method on the npc humanoid to certain points along your path. These points are like corners or just anywhere the npc will change direction

so i would need multiple points around the map, just for the units to transverse the map?

I think I understand, i was watching “Noob Army Tycoon” characters , and i see the points. How can i detect if the character is at the point they to be at?

Because you’re calling the method to one point, use the movetofinished event to detect if the character has reached a specific point. Also, you could also get the point they’re at by checking the NPC’s distance compared to all the points then the nearest point would be the point they’re at