Agents getting stuck on other agents

image

When one of my agents stops to carry out building (Lock When Not Moving is ticked to stop them rotating around), it is quite common that another agent trying to pass will get stuck between them and the building (see image). You can see in the image that they have calculated to go around the stopped agent but they will stay stuck there until the agent finishes and walks away. I am sure this is an easy fix but I am struggling to figure it out. Many thanks

Hi

Local avoidance is, as the name implies only a local planning technique. It will just look at what seems best at the moment, but it doesn’t have much long term thinking. Therefore, if you want obstacles that agent can plan around it’s best to add them as proper obstacles to the navmesh. I’m not sure which graph type you are using, but if you are for example using a recast graph then a NavmeshCut component would work fine.

See also https://arongranberg.com/astar/docs/graph-updates.php

Hi Aron, So I am already using the navmesh cut for when buildings are placed which is working great but the agent is getting caught between the building foundation that has been placed and another agent that has stopped - are you suggesting that I make the agent that has stopped an obstacle (and do a cut out of the namvesh) and then when they have finished doing the building work I update the graph again so that part of the graph is added back. Is this really the only way as that seems inefficient - I could have loads of builders at any one time meaning the graph will be constantly being updated. Previously I didn’t have “lock when not moving” enabled in the RVO controller on each agent and when an agent stopped to build they would move out of the way of the other agent and it looked really bad, now I have “lock when not moving” enabled the builder stays in place but now the other agent gets stuck between them and the building. Basically it seems like the local avoidance isn’t taking into account that one of the agents is locked in place and the one that is getting stuck is moving as if the other will move out of the way.

Yes, that’s what I am suggesting.
Alternatively you could of course do what most games do with regards to builders: just let other characters pass through them :p.
Navmesh cuts are pretty fast, so unless you have a lot of update per second I think it should be fine.

The local avoidance does take the locked agent into account, but it is not possible for it to realize that it cannot get through the small gap between the locked agent and the building, so it gets stuck in a local optima.

Hi Aron, ok thanks for the response. This is what I will do

Hi Aron,

Whats the best way to use this with a grid graph? I’ve tried attaching a dynamic grid obstacle to the agent. Enabling it when the agent has stopped and disabling when moving but it doesnt seems to carve out the walkable area.

1 Like

Hi Archaos,

thought I would respond (I am the original author of the query) as I did get this resolved (at least mostly) - you can do something like this:

An issue I do have is if another colonist is really close behind when this does a cutout they get trapped in the cut out because they are now off grid - I just haven’t got round to implementing a fix for this but sure you can come up with something yourself if this becomes a problem.

Hope this helps.

Regards,

Sam

1 Like