I’m currently trying to remove a tree during runtime. I’m successfully removing the visual for the tree as well as the tree instance from the tree instance array, but the tree collider remains in the scene. I’ve also verified that the tree instance array for the terrain collider is being updated as well.
I’ve seen various “hacks” to get around this, but most of them don’t work:
terrainCollider.enabled = false; terrainCollider.enabled = true;
This works, but takes a ridiculously long time for large terrains.
I’ve also seen
float[,] heights = terrainData.GetHeights(0, 0, 0, 0); terrainData.SetHeights(0, 0, heights);
But that no longer works.
Either way, these are hacky. Ideally there would be a " dirty region" update I could do, but nothing seems to fit this use case. At this point, it feels like a shortcoming of the system.
Is there a better way to remove trees with their colliders?