I am new to the asset and got it because I couldnt solve the AI bunching up/ not avoiding eachother with the Default Navmesh Agent. I have set up AStar with RVO and when the agents are all moving they avoid eachother nicely.
However, once the ones in the front stop moving (reach the player target) the ones in the back keep running forward/trying running through/into the stopped ones, which pushes the crowd forward in an undesired way.
I might tack on some more questions I have as I continue to read all the documentation.
I am using root motion to control my characters, so all I need from a path is the direction. Currently In my script i turn off the aiPath from moving in Awake so only rootmotion moves the character:
_aiPath.canMove = false;
Then I use the steering target to set the direction to run:
Since agents arent obeying the stopped characters as obstacle in front of them, maybe when I set to Idle I should be doing something like this: GraphNode node = AstarPath.active.GetNearest(transform.position).node; if (node.Walkable) { node.Walkable = false; }
Then caching it and turning that node back on when the character starts moving again??
This kind of works for smaller crowds, but the same undesired pushing behavior happens with bigger crowds:
Edit:
Something tells me the graph isnt being updated,
i found this: gg.CalculateConnectionsForCellAndNeighbours(x,z);
But i cant figure out how to get the correct x,z based on my current node?
instead this: gg.CalculateConnections((GridNodeBase)node);
kind of works, but i fear it might recalculate the whole graph? and this is being called constantly by multiple agents.
Also it makes them bug out pretty hard, some run in circles and others throw errors /warnings about not finding a path. However the ones that dont bug out seem to spread out a tiny bit more…
Tried this and it doesnt seem to turn off any nodes visibly on the graph anymore? no difference in crowd response either: AstarPath.active.AddWorkItem(new AstarWorkItem(() => {
** // Safe to update graphs here**
** var node = AstarPath.active.GetNearest(transform.position).node;**
** node.Walkable = false;**
** TurnBackOnLastNode();**
** _currentNode = node;**
** }));**
This doesnt seems to completely undo the Node.Walkable = false
GraphNode node = AstarPath.active.GetNearest(transform.position).node;
if (node.Walkable)
{
node.Walkable = false;
TurnBackOnLastNode();
_currentNode = node;
///this seems to undo what we just did?
Bounds bounds = Soldier.PhysicsCollider._collider.bounds;
AstarPath.active.UpdateGraphs(bounds);
So I made the characters parent RB collider much skinner, and changed the AiPath Radius to be wider, they behave better now, but still do not “flank” me. Rather they just group up and stop moving. Which at least no one is pushing eachother forward now
I am trying to understand what this Radius does since it doesnt seem to effect these guys moving through one another? clicked the doc and its a 404 error:
///
\copydoc Pathfinding::IAstarAI::radius
public float radius = 0.5f;
I guess I could try going from a grid graph to a NavMesh graph, and putting a NavMeshCutter on every enemy soldier ? wonder how this compares performance-wise to my above IsWalkable solution?
Update:
This kind of works, with a very small box center 0.2 x 0.2 and no nav modifier suchs as funnel:
With a funnel modifier and thick raycast modifier:
Idk Im a little stumped. I could write something in the AI logic to raycast forward and if they dont have a clear path to the target to pick a different point nearby which might achieve a better result, but it seems like Im doing something wrong since I thought RVO would just handle all this, but it only handles it while they are moving?