I'm using Unity with Arongranberg's A* pathfinding project to move my characters. However, it appears that my characters are contending for a position on the terrain when they are told to move together to a same position.
For example, I have 5 characters being told to move to PositionA
. They will move together based on their waypoints to PositionA
. One of the characters, call it CharacterA
, will reach PositionA
before the rest. Now, the other 4 characters who arrived later will continue to keep walking and "sliding" around CharacterA
. They seem to stop only when CharacterA
moves away from PositionA
so that they could reach their destination to break out of the loop. Even so, only one character can be in PositionA
while the rest will continue to contend for the place.
So, how can I get the characters and objects to know that they have reached their destination and should stop beside the other characters instead of contending for the same place?
A naive method could be I get the characters to detect if they are blocked by something straight ahead of them. If they are, break out of the loop and stop the walking state. But at times when the character hasn't reached his destination yet and is blocked by an object, say another character, breaking out of the waypoint loop will stop him at the wrong destination. I can't recalculate for a new path from his current position either since the blocking object is another character, which the initial pathfinding grid scanning did not take into account. One way is I re-scan the whole terrain for a new grid of nodes with the characters in the scene taken into account. But this wouldn't be efficient and will lag a whole ton.