I want my NPCs to have a set radius around them, that prevents other NPC from entering their space. When given a command to move to a certain position, NPCs should take into account the area around other NPCs and maneuver as if that area is non-navigable. They should also update their route dynamically during movement.
I have tried attaching a NavModifier to each character but this doesn’t seem to work properly. The enemies still end up bunched up together and ignore each others zones.
I could also do a SphereCollision around NPCs that when entered relays some info to stop movement, but this is not what I want.
The effect I want is:
1. Ensure NPCs never enter each others predefined radius
2. NPCs calculate their path taking into account a detour around others' radius on the fly, adjusting their path when other NPCs move and signal if there is no available path to the given point (so I can run other logic when this is the case).
You need to go into the AI controller and change the PathFollowing component to use CrowdFollowingComponent as the component class! This should have them automatically give each other space!
I have tried this and it looks somewhat better (the AI moves more naturally), but how can I control the radius around each NPC as a “no-go zone” for others?
Specifically, if the radius is big enough, and I order an NPC to move to the player, they should find a space closest to the player that also does not overlap the reserved area of other NPCs that may be close.
Is this even possible without custom logic for determining a “free” space around a given point? If not, how should I implement such logic? Would it be a good idea to attach an array of points around the player that indicate where each NPC should position itself and then find a navigable point closest to those? Is there a way to do this using EQs?
After changing the agent radius, the NPCs won’t traverse near walls and other areas but still stand next to each other after arriving at their location. This property seems to only affect the “padding” of the navmesh, but doesn’t solve my issue unfortunately.
Ah. The only thing I can think of is loading up the class in C++ and changing the avoidance angles at this point, which I’m not sure how to do. Hopefully, someone else has an idea for this specific thing.
I haven´t tested it, but what you are looking for is not the agent radius/size (thats more for fintenuing the navmesh, and letting NPCs walk into narrower areas, or for going not to close to walls etc), instead it´s the “RVO Avoidance” and “Detour Crowd Manager”. The latter one seems to be exactly what you want, that one is for making a detour around obstacles.
You can set the avoidance radius for enforcing larger detours.
Thank you @Suthriel! That’s the beauty of how large the engine is. There’s always something new to discover, this will actually help me as well on my own projects I have going on!