Crowd Manager – how to make ai separate/spread more?


I have few ai characters and I’m trying to make them separated - not walking on same path/straight line. I’m changing Separation Dir Clamp with different values, but still I can’t get best result.

What other settings should I change and where I can find tutorial with basic settings for different situations?

Thank you++

This is sample with 4 AI

This is best what I can achieve now - they all spawn in one place 2-3 seconds before this screen shoot. I need them spread much more if possible.

Bump :slight_smile:
Please, my ai can already shot, evade, look for supplies, take cover, crouch and even make espresso, but how to make crowd spread more???

C++ answer will help ?

Yes, C++ answer will can help. Please help )

It’s been a While…

Well there is a Separation Weight that is not exposed to BPs as far as I know…
Separation Dir Clamp is ok - but it should come togethere with Separation Weight to make it more sensitive.
Separation Dir Clamp is just a threshold value for DOT product value → to be considered as Vectors of the same direction.

void MYAICONTROLLER::SetAvoidanceQuality(ECrowdAvoidanceQuality::Type quality)
	UCrowdFollowingComponent* pathfol = Cast<UCrowdFollowingComponent>(GetPathFollowingComponent());
	if (pathfol)

		pathfol->SetCrowdSeparationWeight(2, true);
		pathfol->SetCrowdSeparation(true, true);

Hi. Sorry, I miss your comment. Any help appreciated! However, if this is open for blueprints I think here should be documentation for blueprints too.

Thank you. All what I need I have in blueprints, maybe I will change project to C++, for now this is only reason - ai. I will try this solution, but waiting still for blueprint way. I know too, this is not exposed, weird…

It would be really easy to add this C++ function.

Right-Click on content browser → Choose Create new C++ File → choose blueprint-library name it and create it.
In the generated C++ header file add the following:


//Includes to add
#include "DetourCrowdAIController.h" //Not sure about this one -> just in case.
#include "Navigation/CrowdFollowingComponent.h" 
//Class declarations auto-generated...
    UFUNCTION(BlueprintCallable, Category = DetourCrowd)
    static void SetSeparationWeight(UCrowdFollowingComponent* inCrowdFolowingComponent, int32 inWeight);
//... Add anything you want
// don't forget to close the class declaration score with "};"

In .cpp file this implementation

void UYOURCLASSNAME::SetSeparationWeight(UCrowdFollowingComponent* inCrowdFolowingComponent, int32 inWeight)
         inCrowdFolowingComponent->SetCrowdSeparationWeight(inWeight, true);
         inCrowdFolowingComponent->SetCrowdSeparation(true, true); //Just in case it is not enabled.

Save and Compile

Now you will have this Function available in your Blueprints.

You can take a look in to my answer → It would be the easiest way to integrate it to your project with as less affords possible.

Also I am not sure why people are so ANTI C++ → it is way faster and cleaner than blueprints.
My project are about 90% C++ My blueprints are mostly inherit C++ classes to make visual adjustments and set some parameters/properties like textures/meshes etc…

I can not imagine how would I do it all in BPs even if we assume that BPs had no Limitations → it is an eye sore to manage Complex logic there - and a pain in the butt to maintain it.

Also you mentioned:

This is best what I can achieve now -
they all spawn in one place 2-3
seconds before this screen shoot. I
need them spread much more if

Why wouldn’t you spawn them not in one place?

Random navigable point in radius or something ?

Great! :slight_smile: Now I’m deep in landscape, I will add this asap - thank you a @ColdSteel48 lot!

Why no c++? I work on my game in Game Maker, code only. My friend persuaded me to try Unreal Engine, I have no c++ skills, so I start with blueprints only and it was never problem - doing things or analyse, my structure is clean. I should learn c++, I published my other software done in Delphi, Java and some php for web, but I never start C++ or just C any kind. After over year of daily work with blueprints I can cay, main reason to move to C++ is blueprints limitations in many ways, like this ai, but complex logic is no problem for me. I know, Game Maker script is not C++ but is code and I created in it my own world composition like system for open world and much more, as a single dev (code, idea, structure, level design, materials and more) I’m just trying to make things faster, of course I know, slogan “in Unreal Engine you can do everything with blueprints only” is a lie like a cake in Portal :smiley:

I not remember how I spawn them, for sure I can make any pattern for spawn crowd, like a circle etc just shortly after spawn, they gathering to close each other like on picture.

I keep seeing you everywhere haha. SO I went ahead and added this node, problem is that the crowd controller crowd following component isn’t blueprint read write normally. Is there anyway to override that in the super?

No, you can make your own CrowdFollowingComponent subclass and add this to the character in its constructor and then just keep a pointer (read/write), or you can just get in from CPP GetPathFollowingComponent then cast it to CrowdFollowing.

I will have to warn you guys: Using detour with Separation will ignore NavMeshFilters.

using second method ( in construction script in bp) editor crashes

Show you code, or dont use ConstructionScript try in BeginPlay - better yet to go with the first method. Anyway after some time you will get mad on UE4 and its pathetic AI system and will implement your own.


this is easy to solve, there is a blueprint callable function GetPathFollowingComponent which can cast to crowd controller following component and then you can use that as the target for the new function…

I tried all of this, and it appears to make zero difference in my use case… they still avoid each other the same amount if I call the function or not, and I verified the functions were called…

edit* I ended up just using RVO avoidance, works exactly as I want and better…

1 Like