I am developing RTS game. When I build buildings on the Terrain, any trees that were in that location end up intersecting with the building.
I want to remove all trees from the building's footprint when placing.
Can I use the building's OnTriggerStay to detect tree colliders with a particular tag and destroy the trees? Or is there a better way to clear out these trees?
OnTriggerStay
is the right tool for this job, since I wouldn't expect either your trees or the buildings to have Rigidbodies. At least one of the colliders needs a dynamic body to fire trigger messages. It sounds like you want something more likePhysics.OverlapBoxNonAlloc
to get an array of all the trees overlapping your building's location. \$\endgroup\$