Hello, although I have been reading as much as I could find about the DetourCrowdController class I still dont really understand how to fine-tune its behavior.
This is what I have so far:
Header
UCLASS()
class CROWD_API AMyAIController : public AAIController, public ICrowdAgentInterface
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, Category = "AI")
FName LocationToGoKey;
virtual void Possess(APawn* Pawn) override;
AMyAIController(const FObjectInitializer& ObjectInitializer);
FORCEINLINE UBlackboardComponent* GetBlackboardComp() const { return BlackboardComp; }
FORCEINLINE TArray<AActor*> GetAvailableTargetPoints() { return BotTargetPoints; }
protected:
UBehaviorTreeComponent* BehaviorComp;
UBlackboardComponent* BlackboardComp;
UCrowdFollowingComponent* CrowdComp;
TArray<AActor*> BotTargetPoints;
};
cpp
AMyAIController::AMyAIController(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<UCrowdFollowingComponent>(TEXT("PathFollowingComponent"))) //UPathFollowingComponent
{
UE_LOG(LogTemp, Warning, TEXT("DETOUR"));
CrowdComp = CreateDefaultSubobject<UCrowdFollowingComponent>(TEXT("CrowdComp"));
UCrowdManager* CrowdManager = UCrowdManager::GetCurrent(this);
if (CrowdManager) {
CrowdManager->RegisterAgent(this);
}
CrowdComp->SetAcceptanceRadius(500.f);
LocationToGoKey = "LocationToGo";
}
void AMyAIController::Possess(APawn* Pawn)
{
Super::Possess(Pawn);
CrowdComp->SetCrowdAvoidanceQuality(ECrowdAvoidanceQuality::High);
CrowdComp->SetCrowdCollisionQueryRange(800.f, true);
CrowdComp->SetCrowdSeparationWeight(4.f, true);
float QueryRange = CrowdComp->GetCrowdCollisionQueryRange();
float SeperationWeight = CrowdComp->GetCrowdSeparationWeight();
// enabling this line or not makes no visible difference
//CrowdComp->SetCrowdSeparation(true, true);
bool SepActive = CrowdComp->IsCrowdSeparationActive();
bool SepEnable = CrowdComp->IsCrowdSeparationEnabled();
UE_LOG(LogTemp, Warning, TEXT("QueryRange: %f"), QueryRange);
UE_LOG(LogTemp, Warning, TEXT("SepWeight: %f"), SeperationWeight);
UE_LOG(LogTemp, Warning, TEXT("Active: %i"), SepActive);
UE_LOG(LogTemp, Warning, TEXT("Enabled: %i"), SepEnable);
}
}
As visible from the picture below although my AI pawns are avoiding each other they move equally unrealistic; only that before they ran into each other whereas now they “moonwalk” sideways and sort of shift around the way points.
What I additionally found strange is that even due I doubled and the values suggested in this post: Detour Avoidance Groups - AI - Unreal Engine Forums
I do not witness any visible change in behavior.
Is there away of making the AI move without sliding around in such a messy way?