Update Graph on Runtime after Object is placed

I’m workin on a RTS and as usual, there’s the option to build structures.

in my case I create a Prefab Clone : Parent(Empty)->Model and change the Skin to green/red to indicate the building status. Once it’s placed I’d like to already avoid the placeholder. Even if it’s finished the units can still walk through the new object.

The particular function:

public void CreateBuilding(string buildingName, Vector3 buildPoint, Unit creator, Rect playingArea) //erstellt ein neues Gebäude { GameObject newBuilding = (GameObject)Instantiate(ResourceManager.GetBuilding(buildingName), buildPoint, new Quaternion()); tempBuilding = newBuilding.GetComponent<Building>(); if (tempBuilding) { tempBuilding.ObjectId = ResourceManager.GetNewObjectId(); tempCreator = creator; findingPlacement = true; tempBuilding.hitPoints = 0; tempBuilding.SetTransparentMaterial(notAllowedMaterial, true); tempBuilding.SetColliders(false); tempBuilding.SetPlayingArea(playingArea); var guo = new GraphUpdateObject(tempBuilding.GetComponent<Collider>().bounds); //ToDo: A* Neu Scannen AstarPath.active.UpdateGraphs(guo); } else Destroy(newBuilding); }

I tried to follow the example from the documentation with the guo part but this doesnt work in this case. Maybe I misunderstood the function of this method.


That looks like it should work.
Does it detect the building if the graph is scanned from the A* inspector?

You are calling “tempBuilding.SetColliders(false);”
I’m not completely sure what that does, but it looks like it might be disabling the colliders. I think that for disabled colliders the bounds are empty.

Did you check if the bounds are empty as indicated in my edit?

Sorry for the late answer (forgot this problem^^): I made a trivial error, it works now^^