Just wanted to let people know that if you want to check for the Attributes of a model which is your unit then you can do so by doing this:
-- this not only allows you to check attributes but completely ignore any with this attribute too
-- This is useful for custom ai systems/swarms allowing the AI to separate from the swarm when it wants too allowing the independent and unified control between the swarm AI and also the models own Ai.
-- You will need to edit line 225~ Just before the bulkmove from workspace.
if unitParts[id].PrimaryPart:GetAttribute("SwarmIgnore") == false then
-- Update position and velocity
local newPos = myPos + vel * dt
unitPos[id] = newPos
unitVel[id] = vel
insert(movePos, newCFrame(newPos.X, UNIT_HEIGHT / 2, newPos.Y) * UNIT_ORIENTATION)
insert(moveParts, unitParts[id])
end
For anyone with the same question, I tested this server-side with 1000 units and let the client do the part movement and it ran fine, even on my phone.
local time = (nextwaypoint-preciouswaypoint).Magnitude/walkspeed
local diffY = (NPC:GetPivot().Position*Vector3.yAxis):FuzzyEq(nextwaypoint*Vector3.yAxis,1)
if diffY then task.wait(time) jump end
HANDS DOWN THE COOLEST THING I’VE SEEN IN MY QUEST TO LEARN MORE ABOUT PATHFINDING.
Been having a hard time trying to make a crowd of AI that is not only performant, but natural (especially when going through tight spaces.) It also seems to fix my issue of AI getting stuck in edges as the flowfield lets them nudge their way into a space, even when there’s a lot of them!
Flowfield is a really awesome concept, and this module made it accessible for me, which is so awesome. For anybody considering a game where there will be a lot of NPCs, try considering flowfield (and this module aswell.)
(still gotta tweak mine a little bit, but overall it seems pretty functional)
updated CFrame every heartbeat (~60 times every second)
It was very unoptimized and incomparable to my current system that uses the standard model of calculating position data on the server, sending it (with compression) through RemoteEvents, and rendering on the client.
Here’s a video of it handling 400 moving units with an average of ~12 KB/s, and the framerate is actually 60 FPS when I’m testing it on the actual Roblox client + not recording via OBS.
Funnily enough, I’ve literally tested 2000 moving units and it only racked up to about ~50 KB/s at ~45 FPS which is genuinely impressive. But eitherway, I probably couldn’t have done it with Roblox’s normal pathfinding, so this module rocks.
seems it doesnt care much about rotation, probably intended behaviour but it should be possible to easily add support for atleast some dimensions of rotation