GridGraph update and non-convex collider

Hello!
I’m trying to update part of GridGraph in runtime after instantiating game object with non-convex collider (collision testing option is on).
I’m using AstarPath.active.UpdateGraphs(b), where b is bounds of game object, but no results (graph nodes still walkable). If I check on convex option of the collider all works fine.
When I’m using AstarPath.active.Scan(), all works as expected even with non-convex collider.
What I’m doing wrong?

Developer! 1 month later - still no answer! Why you do not answer?

Hi

Could you show a bit more of the code that you use? Have you checked that the bounding box is correct?

Bounds bs = new Bounds();
foreach (Collider collider in go.GetComponentsInChildren<Collider>())
{
	bs.Encapsulate(collider.bounds);
        bs.Expand(2);
}
Physics.SyncTransforms();
AstarPath.active.UpdateGraphs(bs);

This code work perfect in previous versions of A*. But in new it does nothing with non-convex colliders. With convex - it work fine.

You should call SyncTransforms before you check the collider bounds.
Also double check that the final bounding box is correct (e.g. Debug.DrawLine(bs.min, bs.max, Color.red, 5)).

Also note that your bounding box will always contain the world origin, which might not be what you want.

Which version of the package are you using?

4.3.31
As I said before problem with non-convex shape: if I add box collider to gameobject, UpdateGraphs does it’s work as expected. But I need to use non-convex collider :roll_eyes:.

I cannot replicate the issue in a test scene.

Could you please use Debug.DrawLine to ensure the bounding box is correct. Please post a screenshot of the result.

non-convex collider

boxcollider

Hmmm. What are your grid settings?

So if instead of calling UpdateGraphs you call AstarPath.active.Scan() everything works as expected?


Yes, if I call Scan it will do what I want even with non-convex

I’m not sure is happening. UpdateGraphs uses the exact same code as Scan.

Could you show what your non-convex collider looks like?

Аннотация 2020-08-12 170952

may be problem in collision testing?

I guess, but I have no idea what might cause it. As I said, Scan uses the same code as UpdateGraphs.

When you tried the scan, did you call it from your code or did you use the button in the inspector?

I’m use button in inspector

What happens if you call AstarPath.active.Scan() at the same place you would have called UpdateGraphs?

I replaced AstarPath.active.UpdateGraphs(bs); with AstarPath.active.Scan() and it works as I want

Ok, I have no idea why that is happening. Would it be possible for you to share a small example scene that shows this issue?

Ok, I will try as soon as possible

1 Like

https://mega.nz/file/x0NmWITA#GWpe0BKwRqkAFjRRq2cNF2APmUum9CHIjlq4ZxFaeBk