I’m working on a zombie system and I’m wondering how I can make actual realistic hordes of zombies that don’t clump up and form a “train” when chasing a player. My first attempt at this was to add a pathfinding “hitbox” with a pathfinding modifier inside it that prevents the zombies from pathfinding through each other.
However, this method did not seem to work, when I tried this out with 4 - 5 zombies, they kept “stuttering” and constantly recalculating their path and making weird movements. Below is the code I am currently using for the zombies.
local ServerStorage = game:GetService("ServerStorage")
local SimplePath = require(ServerStorage.Modules.SimplePath)
local zombie = script.Parent
local humanoid = zombie:WaitForChild("Humanoid")
local humanoidRootPart = zombie:WaitForChild("HumanoidRootPart")
local Path = SimplePath.new(zombie)
Path.Visualize = true
while true do
local nearestCharacter = Path.GetNearestCharacter(humanoidRootPart.Position)
if nearestCharacter then
if nearestCharacter.PrimaryPart then
Path:Run(nearestCharacter.PrimaryPart.Position + nearestCharacter.PrimaryPart.AssemblyLinearVelocity * 0.15) -- Predict the player's movement.
end
end
task.wait()
end
(Note that I am using the SimplePath module to achieve this.)