Registering Player Character with UCrowdManager

So I have a number of AI entities running around and using Detour Crowds, which is great, however they aren’t avoiding the player character, which leads to some awkward situations.

Looking around I found FCrowdAvoidanceConfig | Unreal Engine 5.2 Documentation which tells me that the player character

Actors that should be avoided, but are not being simulated by crowd (like players) should implement CrowdAgentInterface AND register/unregister themselves with crowd manager:

UCrowdManager* CrowdManager = UCrowdManager::GetCurrent(this); if (CrowdManager) { CrowdManager->RegisterAgent(this); }

So I created a MyCharacterC based on Character.h, that I plan on reparenting my MyCharacter blueprint to. I added

include “Navigation/CrowdFollowingComponent.h”
to the headers, but I am not sure of where to define the UCrowdManager class, or where to execute that line.

Running 4.7.3 if that has any bearing on it.

Much appreciated!

I have exactly the same problem. Did you solve it ?

Try this:
a) Create your own class - child of ICrowdAgentInterface. For example:

class UCharacterCrowdAgentInterface: public UActorComponent, public ICrowdAgentInterface

	virtual FVector GetCrowdAgentLocation() const override;
	virtual FVector GetCrowdAgentVelocity() const override;
	virtual void GetCrowdAgentCollisions(float& CylinderRadius, float& CylinderHalfHeight) const override;
	virtual float GetCrowdAgentMaxSpeed() const override;
	virtual int32 GetCrowdAgentAvoidanceGroup() const override;
	virtual int32 GetCrowdAgentGroupsToAvoid() const override;
	virtual int32 GetCrowdAgentGroupsToIgnore() const override;
	virtual void InitializeComponent();

b) Overide this functions(can see UCrowdFollowingComponent ) + register it in Crowd Manager:

void UCharacterCrowdAgentInterface::InitializeComponent()
	UCrowdManager* CrowdManager = UCrowdManager::GetCurrent(this);
	if (CrowdManager)
		ICrowdAgentInterface* IAgent = Cast<ICrowdAgentInterface>(this);

c) Add it like component to your pawn (or character) (can do this in constructor of pawn class)

I don’t know if this is right. The only docs available say you should implement the agent interface in your actor.

I can’t believe this system still isn’t documented. Like, at all.

Yeah, it remains an undocumented mystery but for the inline code comments.