A* Pathfinding Project

Way to have "DynamicGridObstacle" work on multiple colliders in the same object?


In my code I need to have multiple colliders in one object, but Dynamic grid obstacle only counts the first collider. My colliders are automatically generated and I can’t seperate them into different objects. Is there a away to make this work?



You could att a DynamicGridObstacle component to each child that has a collider. That would work even though it would be slightly inefficient.

Or you could attach a trigger collider on the root object with the DynamicGridObstacle component that you configure such that it encapsulates the whole object (including child colliders).


It’s not multiple children that have colliders, it’s one child with multiple colliders.

As for the trigger collider, my collider components dynamically change (damage redraws the collider) so unless there’s a way to make trigger colliders automatically update I think that’s a dead end as well


oh, I see.
Not out of the box I’m afraid. What you would have to do is modify the DynamicGridObstacle script so that instead of checking just one attached collider’s bounding box it checks all attached colliders and creates a bounding box that encapsulates all of them.


This helps, I am trying out MeshBounds which will probably give me an approximate bounds of my object, which is usable, but not as exact as I’d want. Happen to know off the top of your head if there’s a way to reference a collider by order of appearance in C#?


Maybe GetComponent<BoxCollider>() or something similar?