GraphUpdateScene using bounding box and not collision box

Oh yeah, I should probably include my code in case someone else has a similar question in the future.

Attach this to the gameobject

public class NoPath : MonoBehaviour
{
    void Start()
    {
        var guo = new NoPathGraphUpdateObject();
        guo.bounds = GetComponent<Collider>().bounds;
        // Update the graph and apply tags
        AstarPath.active.UpdateGraphs(guo);
    }
}

Then keep this in your project:

public class NoPathGraphUpdateObject : GraphUpdateObject
{
    public override void Apply(GraphNode node)
    {
        // Make sure that the object's layer and the layer mask here match
        Collider[] colliderChecker = Physics.OverlapSphere((Vector3)node.position, 0.5f, 1 << 17);
        if (colliderChecker.Length > 0)
        {
            node.Tag = 1;
        }
    }
}
2 Likes