AI Fan-out follow

I would try with RVO instead of detour.

Ok so here you go:

Create a New C++ class that derives from Blueprint library (in editor).
Open a Header File (the one with .h extension).

add includes (above #include#File_name#.generated.h”):

#include "GameFramework/Character.h"
#include "GameFramework/CharacterMovementComponent.h" //not sure if needed - just in case.

And add this code below the GENERATED_BODY()

    public:
    UFUNCTION(BlueprintCallable, Category = "RVO")
    static FORCEINLINE void EnableRVO(ACharacter * chararacter, bool enabled)
    {
        if(!IsValid(character))
        {
              return;
        }
        if(!IsValid(chararacter->GetCharacterMovement()))
        {
              return;
        }

        chararacter->GetCharacterMovement()->SetAvoidanceEnabled(enabled);
    }
    
    
    UFUNCTION(BlueprintCallable, Category = "RVO")
    static FORCEINLINE void SetRVORadius(ACharacter * chararacter, float radius )
    {
        if(!IsValid(character))
        {
              return;
        }
        if(!IsValid(chararacter->GetCharacterMovement()))
        {
              return;
        }

    chararacter->GetCharacterMovement()->AvoidanceConsiderationRadius = radius;
    }
    
    
    UFUNCTION(BlueprintCallable, Category = "RVO")
    static FORCEINLINE void SetRVOWeight(ACharacter * chararacter, float weight)
    {
        if(!IsValid(character))
        {
              return;
        }
        if(!IsValid(chararacter->GetCharacterMovement()))
        {
              return;
        }   

        chararacter->GetCharacterMovement()->SetRVOAvoidanceWeight(weight);
    }

Hey everyone.

So I’m making a arena survival shooter, think like CoD Zombies. Right now I have my AI following me, but the problem is that it does that in a single line, and it becomes really boring. I know that CoD does something similar, but my maps are fairly open, so you can’t get stuck that easily in corners.

So what I would like to do is either have the AI come as a big wave instead of a single line, or what would be even better is to have it take different paths. I tried modifying the Crowd Avoidance Radius, but apparently it can’t be done for a single Character Movement. I also wanted to assign different cost to paths already taken, again, not exposed in Blueprints.

So anyone has any tips/ideas how this behaviour would be possible? Keep in mind I have a fairly large amount of AIs at once, 50+ in the game, so if possible I would like to avoid constant Environment Queries.

How would that differ? Right now I think I have both Crowd Avoidance and RVO enabled, so that might be bad…Does RVO’d AI need to be a child of Crowd Detour? Do you possibly mean adjusting the weights of RVO at runtime? I have never tried it before, in fact this is the first time I even read up about RVO, so that’s the only reason I even know about weights.

Both are not working together and yes I actually mean to adjust weights in runtime maybe based on distance to player also you can adjust the radius of character. RVO is simple and much cheaper solution, However it is poorly implemented in UE - it dosen’t take a navigation in to account - means they can try to avoid each other and walk in to an obstacle - but if the density of your map is not much dense then it can work pretty well. With RVO you also can have much more AI spawned in runtime.

No, RVOd AI should not be a child of Detour it works with a regular movement component of character.

You mentioned that your map is fairly open - then IMO RVO will help you much more to Have AI separation from each other - basically RVO will just try to separate the AI from each other, which means they atleast won’t move in streight line - You should play with Weights and then you can obtain a nice behaviour.

For Instance I have around 250-300 characters on map with RVO enabled and still around 60 FPS with slightly tweaked MovementComponent.

I think that weights are not exposed to BPs but c++ part of it is fairly easy.
You can also tweak the MovementComoonent to gain better performance - but it is another question.

Hey, sorry for a bit of a late reply. I just got around to checking out UE4 again. It looks like it isn’t possible to set either Weight or Radius in BP. Could you possibly give me a short c++ code that I can drop in the project? I’m not sure how to go around to setting it at runtime :confused:

yet again I’ve found more useful stuff from you regarding AI on the forums, thanks my dude.

I am planning to release an YT explanationary video in how to make Efficient AI, and maybe once I will finish with my game I will make a plugin for that.