Alternative with higher performance for Dynamic Obstacles?

HomeForumsA* Pathfinding ProjectFeature RequestsAlternative with higher performance for Dynamic Obstacles?

This topic has 1 voice, contains 1 reply, and was last updated by  marctro 139 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
Author Posts
Author Posts
December 31, 2011 at 15:54 #1213

marctro

Ah this dynamic obstacle topic is something I can’t let go^ ;)
The ollowing gets a bit long… but maybe then it’s better understandable:

Ok, although I have seen that most mass pathfinding behaviors are be done by some crowd algorithm I am not content with what is available either in Unity3D or the Local Avoidance here (judging by the video clips). I explain why: the avoidance only seems to work within a certain degree of the character. Therefore a “Blobb” of Characters will be accumulated which can hardly dissolve themselves again. The reason for this is, that the pathfinding does not include dynamic characters. That’s why I am not convinced of the Avoidance/Crowd extensions. Now I have tried to solve mass pathfinding with 2 attempts by using pure A*:

1.) Update the WHOLE grid in runtime every 1-2 seconds within a global script and WITHOUT using the DynamicObstacle Script at all, and characters search a new path only each second. This works quite well, performance is OK.

2.) Don’t update the whole grid, but instead attach a DynamicObstacle Script to each character and make them update in timed delays as above.

Strangely enough the 2nd solution has much worse performance than the first on the same gridsize, for I don’t know what reason. Maybe the grid is updated much more often in solution 2 compared to solution 1.

But a single major problem they both share: and that is when you try to move a *group* of characters to a target. What happens is this: the characters in front will leave an island of disabled nodes behind (for a short time) each couple of seconds causing the characters walking behind trying to evade these “islands”. They’ll eventually get to the target but the path they take looks strange.

Now I thought how did “Age of Empires I” solve this issue? (Amazing game btw., one can learn so much from it!). Because they also seemed to use pure A* pathfinding and without any crowd behavior, nor local avoidance. Despite that you were able to steer groups of characters, without them “falling apart”! I think they solved it this way:

They only create a “blocked/disabled island of nodes” when the character comes to a stop. Which means if his speed is < 0.1 or something like that. As long as he is walking he will NOT produce any disabled nodes and therefore you could steer groups of characters walking behind each other and without strange "turnaround" behaviors, because they all follow along the given path.

This is something I should be able to figure out myself with your library, but I am still trying to understand what the DynamicObstacle Script really does. Though I thought it would be a nice feature if such a feature was included in the package.

So my feature request would be:
- A character should only produce an "island of disabled nodes" when he stops
- It would also require that there is an option to ignore moving characters when recalculating the whole grid (so "islands" will only be created on standing characters)

Maybe this is more difficult to implement than I think it is, but I guess it would solve 2 problems: on the one hand you could control groups of characters in a decent way without any crowd/localavoidance, the same way as in Age of Empires 1, and on the other hand the performance would be better than the actual DynamicObstacle Script.

December 31, 2011 at 17:25 #1214

marctro

By the time I have written this long text I have figured it out myself… you only need to add a new layer e.g. layer 8 which you call “Moving”, then add following Code in the AIFollow.cs and simple change the layer when the speed goes under a certain value: (don’t forget to initialize the variables outside the method)

void Update()
{
current_pos = transform.position;
float speedActual = (current_pos - last_pos).magnitude/Time.deltaTime;
last_pos = current_pos;

if(speedActual<0.01F)
{
Debug.Log(speedActual);
transform.gameObject.layer = 0;
}
else
{
transform.gameObject.layer = 8;
}

I have chosen to update the whole grid instead of using the DynamicObstacleScript. So I simply added a rescan Code on the Main Camera with that line InvokeRepeating(“gridScan”,0.0F,1.0F); in the Start() function and the method public void gridScan() { AstarPath.active.Scan(); } .

Now the grid only disables the specific nodes when the character is standing still. Need to do some experimenting with it, for I don’t know if the changing of layers will cause unexpected results (such as e.g. enemies not finding opponents if they are in another layer…)

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Alternative with higher performance for Dynamic Obstacles?
Your information:






<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>