Is it possible to use Roblox’s current path finding system (or even make your own custom one) with flocking behaviors? For example, all the AI’s (whether it be zombies, herds, or whatever animal) move in the general direction of the group with spacing and alignment all with path finding around obstacles around them?
Here’s a link for flocking behaviors by the way, however it does not have path finding incorporated with it:
This is absolutely possible! Steering is all about the compilation of behaviors, flocking is traditionally just those three but you can add in extra steering forces (or remove them if you think they are appropriate). For example, the Zombie model that I made in the toolbox actually has one of these behaviors, separation (although for some reason I called it repulsion? Don’t ask me why) combined with an arrival steering, which is basically just a force pushing towards the next waypoint. If you wanted more interesting group behavior you could add alignment and cohesion if you wanted your AIs to have more of a group dynamic.
Here is the set of articles that I used back in the day, it goes into other steering behaviors.
If you want to see separation in action, pull up the Drooling Zombie model and look inside of ModuleScripts.Roblox_AIUtilities.
That is a distinct possibility. In Roblox it might be okay since NPCs and walls are often solid and we take care of making sure the characters don’t clip into walls (a force can drive an NPC into a wall but it won’t push through). But if you want your characters to avoid walls, you will likely want to add another component to your medley of steering behaviors which steers away from solid objects you don’t want the characters bumping into. This force should only kick in if the character detects that they are close to a wall. Otherwise you might as well save yourself the computation and just set this component of the force to 0.
Ok, I successfully added a separation vector for my AI’s. However, mine is not using a body force but rather using the humanoid’s MoveTo, so it goes to the target point and keep their distance from nearby AIs at the same time.
There is an issue though. When the AIs get close enough to a point with multiple other AIs also in the area, they constantly “jitter”. I am certain this effect is caused because the AI’s keep trying to push towards the point but get “backed up” when they get into range of each other. This throws them into a cycle, creating the “spazzing” effect.
Hmm, there are several things that could be causing this. Some things to try:
Consolidate all of the forces into a single mover, in this case I recommend a VectorForce. Basically what you’ll do on your update cycle is sum all of the forces you want to act on your agent and apply that through the VectorForce.
Add more damping to the forces. Quite often you’ll want to make sure that your driving forces get weaker when the agent is very close to the goal. That way even if they are competing with each other the effects won’t be as dramatic. I’m not 100% sure if Humanoid:MoveTo gets weak when it nears the goal – it may still act at full force. If so, this is why the previous bullet is so useful as you get full control over the force that gets applied.